X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=blobdiff_plain;f=maintenance%2FcleanupBlocks.php;h=cbf008415e2e199e2350548219ff6c12b3493be5;hb=c23c2b1c53824311bed3987d07bc0653aee6450e;hp=37417c73d18c33a3929c4d250ee0e664ecf912bf;hpb=7ff01f46c40975098590290918f98893c7f65118;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/cleanupBlocks.php b/maintenance/cleanupBlocks.php index 37417c73d1..cbf008415e 100644 --- a/maintenance/cleanupBlocks.php +++ b/maintenance/cleanupBlocks.php @@ -44,8 +44,9 @@ class CleanupBlocks extends Maintenance { $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 = []; @@ -54,8 +55,8 @@ class CleanupBlocks extends Maintenance { 'ipblocks', [ 'ipb_user' ], [ - "ipb_user >= $from", - "ipb_user <= $to", + "ipb_user >= " . (int)$from, + "ipb_user <= " . (int)$to, ], __METHOD__, [ @@ -118,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( @@ -127,8 +128,8 @@ class CleanupBlocks extends Maintenance { [ 'ipb_id', 'user_name' ], [ 'ipb_user = user_id', - "ipb_user >= $from", - "ipb_user <= $to", + "ipb_user >= " . (int)$from, + "ipb_user <= " . (int)$to, 'ipb_address != user_name', ], __METHOD__ @@ -147,5 +148,5 @@ class CleanupBlocks extends Maintenance { } } -$maintClass = "CleanupBlocks"; +$maintClass = CleanupBlocks::class; require_once RUN_MAINTENANCE_IF_MAIN;