X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FBlock.php;h=2bae13b77738ea416ea2122f8e3f9cc7a46c1da5;hb=043a36858bcb9e2085d2cec95dc816f3770fbb48;hp=e23a8ff1432cfc919de6a1009dbf5d5bf4c84162;hpb=dcee65673b531ebe39a093ee0c021a926ea74ad9;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Block.php b/includes/Block.php index e23a8ff143..2bae13b777 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -539,10 +539,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 ); @@ -1137,15 +1134,18 @@ class Block { return; } - DeferredUpdates::addUpdate( new AtomicSectionUpdate( + DeferredUpdates::addUpdate( new AutoCommitUpdate( 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 ); + } } ) ); }