X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FcleanupBlocks.php;h=5c5c88f0b0fb788dc81a50a70862c872db79ac7d;hb=b7dc54d5007969d814e6d1aee4e7bed7c4dbaca9;hp=f489333f8ffe1387b7e315fcfa6131132759877b;hpb=f428f95ac49e71bde47bc982e31ff60b3ef41706;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/cleanupBlocks.php b/maintenance/cleanupBlocks.php index f489333f8f..5c5c88f0b0 100644 --- a/maintenance/cleanupBlocks.php +++ b/maintenance/cleanupBlocks.php @@ -39,12 +39,14 @@ class CleanupBlocks extends Maintenance { public function execute() { $db = $this->getDB( DB_MASTER ); + $blockQuery = Block::getQueryInfo(); $max = $db->selectField( 'ipblocks', 'MAX(ipb_user)' ); // Step 1: Clean up any duplicate user blocks - for ( $from = 1; $from <= $max; $from += $this->mBatchSize ) { - $to = min( $max, $from + $this->mBatchSize - 1 ); + $batchSize = $this->getBatchSize(); + for ( $from = 1; $from <= $max; $from += $batchSize ) { + $to = min( $max, $from + $batchSize - 1 ); $this->output( "Cleaning up duplicate ipb_user ($from-$to of $max)\n" ); $delete = []; @@ -65,11 +67,14 @@ class CleanupBlocks extends Maintenance { foreach ( $res as $row ) { $bestBlock = null; $res2 = $db->select( - 'ipblocks', - Block::selectFields(), + $blockQuery['tables'], + $blockQuery['fields'], [ 'ipb_user' => $row->ipb_user, - ] + ], + __METHOD__, + [], + $blockQuery['joins'] ); foreach ( $res2 as $row2 ) { $block = Block::newFromRow( $row2 ); @@ -114,8 +119,8 @@ class CleanupBlocks extends Maintenance { } // Step 2: Update the user name in any blocks where it doesn't match - for ( $from = 1; $from <= $max; $from += $this->mBatchSize ) { - $to = min( $max, $from + $this->mBatchSize - 1 ); + for ( $from = 1; $from <= $max; $from += $batchSize ) { + $to = min( $max, $from + $batchSize - 1 ); $this->output( "Cleaning up mismatched user name ($from-$to of $max)\n" ); $res = $db->select(