X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2Fcdb.php;h=2e252adb037b3303266706d052ea00d024b11d94;hb=7c9909f09dbb1dad994a0cc8b89db1a97b74073b;hp=9e56e1beb1d171afc79bcbf9ef920e9d70e694ff;hpb=3dc6844ae15512838c9ec70b4903090c2723967f;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/cdb.php b/maintenance/cdb.php index 9e56e1beb1..2e252adb03 100644 --- a/maintenance/cdb.php +++ b/maintenance/cdb.php @@ -21,9 +21,11 @@ * @todo document * @ingroup Maintenance */ +use \Cdb\Exception as CdbException; +use \Cdb\Reader as CdbReader; /** */ -require_once( __DIR__ . '/commandLine.inc' ); +require_once __DIR__ . '/commandLine.inc'; function cdbShowHelp( $command ) { $commandList = array( @@ -52,7 +54,7 @@ do { $bad = false; $showhelp = false; $quit = false; - static $fileHandle; + static $fileHandle = false; $line = Maintenance::readconsole(); if ( $line === false ) { @@ -75,7 +77,11 @@ do { } $file = $args[0]; print "Loading cdb file $file..."; - $fileHandle = CdbReader::open( $file ); + try { + $fileHandle = CdbReader::open( $file ); + } catch ( CdbException $e ) { + } + if ( !$fileHandle ) { print "not a cdb file or unable to read it\n"; } else { @@ -91,7 +97,12 @@ do { print "Need to specify a key, Luke\n"; break; } - $res = $fileHandle->get( $args[0] ); + try { + $res = $fileHandle->get( $args[0] ); + } catch ( CdbException $e ) { + print "Unable to read key from file\n"; + break; + } if ( $res === false ) { print "No such key/value pair\n"; } elseif ( is_string( $res ) ) {