Merge "Replace wfGetLBFactory"
[lhc/web/wiklou.git] / maintenance / storage / trackBlobs.php
index a2dc376..a1e157d 100644 (file)
@@ -22,6 +22,9 @@
  * @see wfWaitForSlaves()
  */
 
+use MediaWiki\MediaWikiServices;
+use Wikimedia\Rdbms\DBConnectionError;
+
 require __DIR__ . '/../commandLine.inc';
 
 if ( count( $args ) < 1 ) {
@@ -69,7 +72,7 @@ class TrackBlobs {
                echo "Doing integrity check...\n";
                $dbr = wfGetDB( DB_REPLICA );
 
-               // Scan for HistoryBlobStub objects in the text table (bug 20757)
+               // Scan for HistoryBlobStub objects in the text table (T22757)
 
                $exists = $dbr->selectField( 'text', 1,
                        'old_flags LIKE \'%object%\' AND old_flags NOT LIKE \'%external%\' ' .
@@ -84,7 +87,7 @@ class TrackBlobs {
                        exit( 1 );
                }
 
-               // Scan the archive table for HistoryBlobStub objects or external flags (bug 22624)
+               // Scan the archive table for HistoryBlobStub objects or external flags (T24624)
                $flags = $dbr->selectField( 'archive', 'ar_flags',
                        'ar_flags LIKE \'%external%\' OR (' .
                        'ar_flags LIKE \'%object%\' ' .
@@ -151,7 +154,7 @@ class TrackBlobs {
 
                $textClause = $this->getTextClause();
                $startId = 0;
-               $endId = $dbr->selectField( 'revision', 'MAX(rev_id)', false, __METHOD__ );
+               $endId = $dbr->selectField( 'revision', 'MAX(rev_id)', '', __METHOD__ );
                $batchesDone = 0;
                $rowsInserted = 0;
 
@@ -227,7 +230,7 @@ class TrackBlobs {
 
                $textClause = $this->getTextClause( $this->clusters );
                $startId = 0;
-               $endId = $dbr->selectField( 'text', 'MAX(old_id)', false, __METHOD__ );
+               $endId = $dbr->selectField( 'text', 'MAX(old_id)', '', __METHOD__ );
                $rowsInserted = 0;
                $batchesDone = 0;
 
@@ -315,7 +318,8 @@ class TrackBlobs {
 
                foreach ( $this->clusters as $cluster ) {
                        echo "Searching for orphan blobs in $cluster...\n";
-                       $lb = wfGetLBFactory()->getExternalLB( $cluster );
+                       $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
+                       $lb = $lbFactory->getExternalLB( $cluster );
                        try {
                                $extDB = $lb->getConnection( DB_REPLICA );
                        } catch ( DBConnectionError $e ) {
@@ -337,7 +341,7 @@ class TrackBlobs {
                        $startId = 0;
                        $batchesDone = 0;
                        $actualBlobs = gmp_init( 0 );
-                       $endId = $extDB->selectField( $table, 'MAX(blob_id)', false, __METHOD__ );
+                       $endId = $extDB->selectField( $table, 'MAX(blob_id)', '', __METHOD__ );
 
                        // Build a bitmap of actual blob rows
                        while ( true ) {