Use "break" instead of "continue" inside a switch
[lhc/web/wiklou.git] / maintenance / storage / checkStorage.php
index acf0103..f05be36 100644 (file)
@@ -65,7 +65,7 @@ class CheckStorage {
                } else {
                        print "Checking...\n";
                }
-               $maxRevId = $dbr->selectField( 'revision', 'MAX(rev_id)', false, __METHOD__ );
+               $maxRevId = $dbr->selectField( 'revision', 'MAX(rev_id)', '', __METHOD__ );
                $chunkSize = 1000;
                $flagStats = [];
                $objectStats = [];
@@ -100,8 +100,12 @@ class CheckStorage {
                        $missingTextRows = array_flip( $this->oldIdMap );
                        $externalRevs = [];
                        $objectRevs = [];
-                       $res = $dbr->select( 'text', [ 'old_id', 'old_flags' ],
-                               'old_id IN (' . implode( ',', $this->oldIdMap ) . ')', __METHOD__ );
+                       $res = $dbr->select(
+                               'text',
+                               [ 'old_id', 'old_flags' ],
+                               [ 'old_id' => $this->oldIdMap ],
+                               __METHOD__
+                       );
                        foreach ( $res as $row ) {
                                /**
                                 * @var $flags int
@@ -158,8 +162,12 @@ class CheckStorage {
                        $externalConcatBlobs = [];
                        $externalNormalBlobs = [];
                        if ( count( $externalRevs ) ) {
-                               $res = $dbr->select( 'text', [ 'old_id', 'old_flags', 'old_text' ],
-                                       [ 'old_id IN (' . implode( ',', $externalRevs ) . ')' ], __METHOD__ );
+                               $res = $dbr->select(
+                                       'text',
+                                       [ 'old_id', 'old_flags', 'old_text' ],
+                                       [ 'old_id' => $externalRevs ],
+                                       __METHOD__
+                               );
                                foreach ( $res as $row ) {
                                        $urlParts = explode( '://', $row->old_text, 2 );
                                        if ( count( $urlParts ) !== 2 || $urlParts[1] == '' ) {
@@ -200,7 +208,9 @@ class CheckStorage {
                                        $blobsTable = $this->dbStore->getTable( $extDb );
                                        $res = $extDb->select( $blobsTable,
                                                [ 'blob_id' ],
-                                               [ 'blob_id IN( ' . implode( ',', $blobIds ) . ')' ], __METHOD__ );
+                                               [ 'blob_id' => $blobIds ],
+                                               __METHOD__
+                                       );
                                        foreach ( $res as $row ) {
                                                unset( $xBlobIds[$row->blob_id] );
                                        }
@@ -224,7 +234,7 @@ class CheckStorage {
                                $res = $dbr->select(
                                        'text',
                                        [ 'old_id', 'old_flags', "LEFT(old_text, $headerLength) AS header" ],
-                                       [ 'old_id IN (' . implode( ',', $objectRevs ) . ')' ],
+                                       [ 'old_id' => $objectRevs ],
                                        __METHOD__
                                );
                                foreach ( $res as $row ) {
@@ -256,12 +266,12 @@ class CheckStorage {
                                                case 'historyblobcurstub':
                                                        if ( strlen( $row->header ) == $headerLength ) {
                                                                $this->addError( 'unfixable', "Error: overlong stub header", $oldId );
-                                                               continue;
+                                                               break;
                                                        }
                                                        $stubObj = unserialize( $row->header );
                                                        if ( !is_object( $stubObj ) ) {
                                                                $this->addError( 'restore text', "Error: unable to unserialize stub object", $oldId );
-                                                               continue;
+                                                               break;
                                                        }
                                                        if ( $className == 'historyblobstub' ) {
                                                                $concatBlobs[$stubObj->mOldId][] = $oldId;
@@ -283,7 +293,7 @@ class CheckStorage {
                                $res = $dbr->select(
                                        'text',
                                        [ 'old_id', 'old_flags', "LEFT(old_text, $headerLength) AS header" ],
-                                       [ 'old_id IN (' . implode( ',', array_keys( $concatBlobs ) ) . ')' ],
+                                       [ 'old_id' => array_keys( $concatBlobs ) ],
                                        __METHOD__
                                );
                                foreach ( $res as $row ) {
@@ -402,7 +412,9 @@ class CheckStorage {
                        $headerLength = strlen( self::CONCAT_HEADER );
                        $res = $extDb->select( $blobsTable,
                                [ 'blob_id', "LEFT(blob_text, $headerLength) AS header" ],
-                               [ 'blob_id IN( ' . implode( ',', $blobIds ) . ')' ], __METHOD__ );
+                               [ 'blob_id' => $blobIds ],
+                               __METHOD__
+                       );
                        foreach ( $res as $row ) {
                                if ( strcasecmp( $row->header, self::CONCAT_HEADER ) ) {
                                        $this->addError(
@@ -481,6 +493,9 @@ class CheckStorage {
                        MediaWikiServices::getInstance()->getMainConfig()
                );
                $importer->setRevisionCallback( [ $this, 'importRevision' ] );
+               $importer->setNoticeCallback( function ( $msg, $params ) {
+                       echo wfMessage( $msg, $params )->text() . "\n";
+               } );
                $importer->doImport();
        }