From: Aaron Schulz Date: Thu, 18 Apr 2013 04:35:33 +0000 (-0700) Subject: Moved Block and Title purgeExpired() functions to onTransactionIdle(). X-Git-Tag: 1.31.0-rc.0~19951 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=4738bc315a1d33a903b6c2ba2e9c1804c7ff823d;p=lhc%2Fweb%2Fwiklou.git Moved Block and Title purgeExpired() functions to onTransactionIdle(). Change-Id: I82b2f4689a42481cd2a476351354f55ded581ff5 --- diff --git a/includes/Block.php b/includes/Block.php index 1d98a29a65..3f00a51626 100644 --- a/includes/Block.php +++ b/includes/Block.php @@ -999,11 +999,16 @@ class Block { * Purge expired blocks from the ipblocks table */ public static function purgeExpired() { - if ( !wfReadOnly() ) { - $dbw = wfGetDB( DB_MASTER ); - $dbw->delete( 'ipblocks', - array( 'ipb_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ), __METHOD__ ); + if ( wfReadOnly() ) { + return; } + + $method = __METHOD__; + $dbw = wfGetDB( DB_MASTER ); + $dbw->onTransactionIdle( function() use ( $dbw, $method ) { + $dbw->delete( 'ipblocks', + array( 'ipb_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ), $method ); + } ); } /** diff --git a/includes/Title.php b/includes/Title.php index 6acffa0a69..fda790fdd9 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -2807,18 +2807,20 @@ class Title { return; } + $method = __METHOD__; $dbw = wfGetDB( DB_MASTER ); - $dbw->delete( - 'page_restrictions', - array( 'pr_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ), - __METHOD__ - ); - - $dbw->delete( - 'protected_titles', - array( 'pt_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ), - __METHOD__ - ); + $dbw->onTransactionIdle( function() use ( $dbw, $method ) { + $dbw->delete( + 'page_restrictions', + array( 'pr_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ), + $method + ); + $dbw->delete( + 'protected_titles', + array( 'pt_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ), + $method + ); + } ); } /**