From e284588df67ef9b40c6755b3517366c0124d2481 Mon Sep 17 00:00:00 2001 From: Amir Sarabadani Date: Fri, 23 Feb 2018 17:58:58 +0100 Subject: [PATCH] Do not run ipblocks cleanup randomly, just do it all the time It's a deferred update and the number of blocks are small Change-Id: I75e0b7dc38b22f8aa7453582d535a8ab8121fd1a --- includes/Block.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/includes/Block.php b/includes/Block.php index bdc6702f91..e0b63ff7da 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -526,10 +526,7 @@ class Block { $dbw = wfGetDB( DB_MASTER ); } - # Periodic purge via commit hooks - if ( mt_rand( 0, 9 ) == 0 ) { - self::purgeExpired(); - } + self::purgeExpired(); $row = $this->getDatabaseArray( $dbw ); @@ -1119,11 +1116,14 @@ class Block { wfGetDB( DB_MASTER ), __METHOD__, function ( IDatabase $dbw, $fname ) { - $dbw->delete( - 'ipblocks', + $ids = $dbw->selectFieldValues( 'ipblocks', + 'ipb_id', [ 'ipb_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ], $fname ); + if ( $ids ) { + $dbw->delete( 'ipblocks', [ 'ipb_id' => $ids ], $fname ); + } } ) ); } -- 2.20.1