Merge "mw.language.convertPlural: Check if matching form exists"
[lhc/web/wiklou.git] / maintenance / cdb.php
index d42f9f7..4590611 100644 (file)
@@ -52,7 +52,7 @@ do {
        $bad = false;
        $showhelp = false;
        $quit = false;
-       static $fileHandle;
+       static $fileHandle = false;
 
        $line = Maintenance::readconsole();
        if ( $line === false ) {
@@ -75,7 +75,10 @@ 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 +94,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 ) ) {