X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2Fcdb.php;h=bda64f3eab1d00c2b0079e67e0426bd197858be9;hb=c69c9394413bd7d676e08f0ee83f49477fbcdcba;hp=270f7a60f3b208bb0f96bb1b6ca6081d2bf022b8;hpb=4736034866f3c1cbda172943348fc396e9a54726;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/cdb.php b/maintenance/cdb.php index 270f7a60f3..bda64f3eab 100644 --- a/maintenance/cdb.php +++ b/maintenance/cdb.php @@ -23,12 +23,12 @@ */ /** */ -require_once( dirname( __FILE__ ) . '/commandLine.inc' ); +require_once __DIR__ . '/commandLine.inc'; function cdbShowHelp( $command ) { $commandList = array( 'load' => 'load a cdb file for reading', - 'get' => 'get a value for a key', + 'get' => 'get a value for a key', 'exit' => 'exit cdb', 'quit' => 'exit cdb', 'help' => 'help about a command', @@ -55,7 +55,9 @@ do { static $fileHandle; $line = Maintenance::readconsole(); - if ( $line === false ) exit; + if ( $line === false ) { + exit; + } $args = explode( ' ', $line ); $command = array_shift( $args ); @@ -67,29 +69,36 @@ do { cdbShowHelp( array_shift( $args ) ); break; case 'load': - if( !isset( $args[0] ) ) { + if ( !isset( $args[0] ) ) { print "Need a filename there buddy\n"; break; } $file = $args[0]; print "Loading cdb file $file..."; - $fileHandle = CdbReader::open( $file ); - if( !$fileHandle ) { + try { + $fileHandle = CdbReader::open( $file ); + } catch( CdbException $e ) {} + + if ( !$fileHandle ) { print "not a cdb file or unable to read it\n"; } else { print "ok\n"; } break; case 'get': - if( !$fileHandle ) { + if ( !$fileHandle ) { print "Need to load a cdb file first\n"; break; } - if( !isset( $args[0] ) ) { + if ( !isset( $args[0] ) ) { 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"; + } if ( $res === false ) { print "No such key/value pair\n"; } elseif ( is_string( $res ) ) {