$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 = [];
'ipblocks',
[ 'ipb_user' ],
[
- "ipb_user >= $from",
- "ipb_user <= $to",
+ "ipb_user >= " . (int)$from,
+ "ipb_user <= " . (int)$to,
],
__METHOD__,
[
}
// 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(
[ '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__