X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/modifier.php?a=blobdiff_plain;f=maintenance%2FpopulateRecentChangesSource.php;h=ac87cf3ecb028853b0a521de986fd99b25e08437;hb=7babd362babcbf7f20adb8e12edb4f4bc1d4249f;hp=452d2135c6ed0d7aa3162861f707b5b7d3b38c99;hpb=b67ab9de01a2eb95875d27a26eb9c30b22edf97e;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/populateRecentChangesSource.php b/maintenance/populateRecentChangesSource.php index 452d2135c6..4ac348672b 100644 --- a/maintenance/populateRecentChangesSource.php +++ b/maintenance/populateRecentChangesSource.php @@ -23,6 +23,8 @@ require_once __DIR__ . '/Maintenance.php'; +use Wikimedia\Rdbms\IDatabase; + /** * Maintenance script to populate the rc_source field. * @@ -39,6 +41,7 @@ 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.' ); } @@ -50,30 +53,28 @@ class PopulateRecentChangesSource extends LoggedUpdateMaintenance { return true; } $end = $dbw->selectField( 'recentchanges', 'MAX(rc_id)', false, __METHOD__ ); - $end += $this->mBatchSize - 1; + $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', - array( $updatedValues ), - array( + [ $updatedValues ], + [ "rc_source = ''", - "rc_id BETWEEN $blockStart AND $blockEnd" - ), + "rc_id BETWEEN " . (int)$blockStart . " AND " . (int)$blockEnd + ], __METHOD__ ); $this->output( "." ); wfWaitForSlaves(); - $blockStart += $this->mBatchSize; - $blockEnd += $this->mBatchSize; + $blockStart += $batchSize; + $blockEnd += $batchSize; } $this->output( "\nDone.\n" ); @@ -83,7 +84,7 @@ class PopulateRecentChangesSource extends LoggedUpdateMaintenance { return __CLASS__; } - protected function buildUpdateCondition( DatabaseBase $dbw ) { + protected function buildUpdateCondition( IDatabase $dbw ) { $rcNew = $dbw->addQuotes( RC_NEW ); $rcSrcNew = $dbw->addQuotes( RecentChange::SRC_NEW ); $rcEdit = $dbw->addQuotes( RC_EDIT ); @@ -103,5 +104,5 @@ class PopulateRecentChangesSource extends LoggedUpdateMaintenance { } } -$maintClass = "PopulateRecentChangesSource"; +$maintClass = PopulateRecentChangesSource::class; require_once RUN_MAINTENANCE_IF_MAIN;