X-Git-Url: https://git.cyclocoop.org/%242?a=blobdiff_plain;f=maintenance%2FupdateRestrictions.php;h=668ba790fa1d5b52e6822fc52833af9470c35ed7;hb=b7d1782e1055cd04338293d1c5ce0f09ffadbff4;hp=2f3fc36534e179b6ffe6c5994ef77534d1823c6a;hpb=36395150104588f2afea866c330b683e4329fa48;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/updateRestrictions.php b/maintenance/updateRestrictions.php index 2f3fc36534..668ba790fa 100644 --- a/maintenance/updateRestrictions.php +++ b/maintenance/updateRestrictions.php @@ -41,24 +41,26 @@ class UpdateRestrictions extends Maintenance { public function execute() { $db = $this->getDB( DB_MASTER ); + $batchSize = $this->getBatchSize(); if ( !$db->tableExists( 'page_restrictions' ) ) { - $this->error( "page_restrictions table does not exist", true ); + $this->fatalError( "page_restrictions table does not exist" ); } - $start = $db->selectField( 'page', 'MIN(page_id)', false, __METHOD__ ); + $start = $db->selectField( 'page', 'MIN(page_id)', '', __METHOD__ ); if ( !$start ) { - $this->error( "Nothing to do.", true ); + $this->fatalError( "Nothing to do." ); } - $end = $db->selectField( 'page', 'MAX(page_id)', false, __METHOD__ ); + $end = $db->selectField( 'page', 'MAX(page_id)', '', __METHOD__ ); # Do remaining chunk - $end += $this->mBatchSize - 1; + $end += $batchSize - 1; $blockStart = $start; - $blockEnd = $start + $this->mBatchSize - 1; + $blockEnd = $start + $batchSize - 1; $encodedExpiry = 'infinity'; while ( $blockEnd <= $end ) { $this->output( "...doing page_id from $blockStart to $blockEnd out of $end\n" ); - $cond = "page_id BETWEEN $blockStart AND $blockEnd AND page_restrictions !=''"; + $cond = "page_id BETWEEN " . (int)$blockStart . " AND " . (int)$blockEnd . + " AND page_restrictions !=''"; $res = $db->select( 'page', [ 'page_id', 'page_namespace', 'page_restrictions' ], @@ -105,8 +107,8 @@ class UpdateRestrictions extends Maintenance { throw new MWException( "Deadlock loop failed wtf :(" ); } } - $blockStart += $this->mBatchSize - 1; - $blockEnd += $this->mBatchSize - 1; + $blockStart += $batchSize - 1; + $blockEnd += $batchSize - 1; wfWaitForSlaves(); } $this->output( "...removing dead rows from page_restrictions\n" ); @@ -124,5 +126,5 @@ class UpdateRestrictions extends Maintenance { } } -$maintClass = "UpdateRestrictions"; +$maintClass = UpdateRestrictions::class; require_once RUN_MAINTENANCE_IF_MAIN;