Tim Starling has submitted this change and it was merged.

Change subject: Moved Block and Title purgeExpired() functions to 
onTransactionIdle().
......................................................................


Moved Block and Title purgeExpired() functions to onTransactionIdle().

Change-Id: I82b2f4689a42481cd2a476351354f55ded581ff5
---
M includes/Block.php
M includes/Title.php
2 files changed, 22 insertions(+), 15 deletions(-)

Approvals:
  Tim Starling: Verified; Looks good to me, approved



diff --git a/includes/Block.php b/includes/Block.php
index 1d98a29..3f00a51 100644
--- a/includes/Block.php
+++ b/includes/Block.php
@@ -999,11 +999,16 @@
         * 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 6acffa0..fda790f 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -2807,18 +2807,20 @@
                        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
+                       );
+               } );
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/59794
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I82b2f4689a42481cd2a476351354f55ded581ff5
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>
Gerrit-Reviewer: Demon <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to