From: Amir Sarabadani Date: Fri, 23 Feb 2018 16:58:58 +0000 (+0100) Subject: Do not run ipblocks cleanup randomly, just do it all the time X-Git-Tag: 1.31.0-rc.0~493^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=e284588df67ef9b40c6755b3517366c0124d2481;p=lhc%2Fweb%2Fwiklou.git 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 --- 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 ); + } } ) ); }