Chad has uploaded a new change for review.
https://gerrit.wikimedia.org/r/97846
Change subject: Proper CdbException handling
......................................................................
Proper CdbException handling
Also fix up usage of print while we're here
Change-Id: Ib7af23f2dc9c65cfd9b4c3b009d358f968a910b2
---
M dumpInterwiki.php
1 file changed, 20 insertions(+), 8 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikimediaMaintenance
refs/changes/46/97846/1
diff --git a/dumpInterwiki.php b/dumpInterwiki.php
index 2ecc8be..83d2e4d 100644
--- a/dumpInterwiki.php
+++ b/dumpInterwiki.php
@@ -34,9 +34,10 @@
protected $langlist, $dblist, $specials, $languageAliases,
$prefixRewrites, $prefixLists;
/**
- * @var CdbWriter
+ * @var CdbWriter|bool
*/
- protected $dbFile;
+ protected $dbFile = false;
+
protected $urlprotocol;
public function __construct() {
@@ -63,9 +64,11 @@
$this->specials = array_flip( array_map( "trim", file(
$this->getOption( 'specialdbs', $default_special_dblist ) ) ) );
if ( $this->hasOption( 'o' ) ) {
- $this->dbFile = CdbWriter::open( $this->getOption( 'o'
) ) ;
- } else {
- $this->dbFile = false;
+ try {
+ $this->dbFile = CdbWriter::open(
$this->getOption( 'o' ) ) ;
+ } catch( CdbException $e ) {
+ $this->error( "Unable to open cdb file for
writing", 1 );
+ }
}
if ( $this->hasOption( 'protocolrelative' ) ) {
@@ -241,9 +244,13 @@
$list = array_keys( $hash );
sort( $list );
if ( $this->dbFile ) {
- $this->dbFile->set( "__list:{$source}",
implode( ' ', $list ) );
+ try {
+ $this->dbFile->set( "__list:{$source}",
implode( ' ', $list ) );
+ } catch ( CdbException $e ) {
+ throw new MWException( $e->getMessage()
);
+ }
} else {
- print "__list:{$source} " . implode( ' ', $list
) . "\n";
+ $this->output( "__list:{$source} " . implode( '
', $list ) . "\n" );
}
}
}
@@ -289,7 +296,12 @@
$entry["iw_url"] = '';
}
if ( $this->dbFile ) {
- $this->dbFile->set( "{$source}:{$entry['iw_prefix']}",
trim( "{$entry['iw_local']} {$entry['iw_url']}" ) );
+ try {
+ $this->dbFile->set(
"{$source}:{$entry['iw_prefix']}",
+ trim( "{$entry['iw_local']}
{$entry['iw_url']}" ) );
+ } catch ( CdbException $e ) {
+ throw new MWException( $e->getMessage() );
+ }
} else {
$this->output( "{$source}:{$entry['iw_prefix']}
{$entry['iw_url']} {$entry['iw_local']}\n" );
}
--
To view, visit https://gerrit.wikimedia.org/r/97846
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib7af23f2dc9c65cfd9b4c3b009d358f968a910b2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikimediaMaintenance
Gerrit-Branch: master
Gerrit-Owner: Chad <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits