Merge "Revert "Log the reason why revision->getContent() returns null""
[lhc/web/wiklou.git] / maintenance / populateRecentChangesSource.php
index 5d5da89..8a56d7d 100644 (file)
@@ -41,32 +41,31 @@ class PopulateRecentChangesSource extends LoggedUpdateMaintenance {
 
        protected function doDBUpdates() {
                $dbw = $this->getDB( DB_MASTER );
+               $batchSize = $this->getBatchSize();
                if ( !$dbw->fieldExists( 'recentchanges', 'rc_source' ) ) {
                        $this->error( 'rc_source field in recentchanges table does not exist.' );
                }
 
-               $start = $dbw->selectField( 'recentchanges', 'MIN(rc_id)', false, __METHOD__ );
+               $start = $dbw->selectField( 'recentchanges', 'MIN(rc_id)', '', __METHOD__ );
                if ( !$start ) {
                        $this->output( "Nothing to do.\n" );
 
                        return true;
                }
-               $end = $dbw->selectField( 'recentchanges', 'MAX(rc_id)', false, __METHOD__ );
-               $end += $this->mBatchSize - 1;
+               $end = $dbw->selectField( 'recentchanges', 'MAX(rc_id)', '', __METHOD__ );
+               $end += $batchSize - 1;
                $blockStart = $start;
-               $blockEnd = $start + $this->mBatchSize - 1;
+               $blockEnd = $start + $batchSize - 1;
 
                $updatedValues = $this->buildUpdateCondition( $dbw );
 
                while ( $blockEnd <= $end ) {
-                       $cond = "rc_id BETWEEN $blockStart AND $blockEnd";
-
                        $dbw->update(
                                'recentchanges',
                                [ $updatedValues ],
                                [
                                        "rc_source = ''",
-                                       "rc_id BETWEEN $blockStart AND $blockEnd"
+                                       "rc_id BETWEEN " . (int)$blockStart . " AND " . (int)$blockEnd
                                ],
                                __METHOD__
                        );
@@ -74,8 +73,8 @@ class PopulateRecentChangesSource extends LoggedUpdateMaintenance {
                        $this->output( "." );
                        wfWaitForSlaves();
 
-                       $blockStart += $this->mBatchSize;
-                       $blockEnd += $this->mBatchSize;
+                       $blockStart += $batchSize;
+                       $blockEnd += $batchSize;
                }
 
                $this->output( "\nDone.\n" );
@@ -105,5 +104,5 @@ class PopulateRecentChangesSource extends LoggedUpdateMaintenance {
        }
 }
 
-$maintClass = "PopulateRecentChangesSource";
+$maintClass = PopulateRecentChangesSource::class;
 require_once RUN_MAINTENANCE_IF_MAIN;