From 4738bc315a1d33a903b6c2ba2e9c1804c7ff823d Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 17 Apr 2013 21:35:33 -0700 Subject: [PATCH] Moved Block and Title purgeExpired() functions to onTransactionIdle(). Change-Id: I82b2f4689a42481cd2a476351354f55ded581ff5 --- includes/Block.php | 13 +++++++++---- includes/Title.php | 24 +++++++++++++----------- 2 files changed, 22 insertions(+), 15 deletions(-) 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 + ); + } ); } /** -- 2.20.1