Moved Block and Title purgeExpired() functions to onTransactionIdle().
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 18 Apr 2013 04:35:33 +0000 (21:35 -0700)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 18 Apr 2013 22:53:28 +0000 (22:53 +0000)
Change-Id: I82b2f4689a42481cd2a476351354f55ded581ff5

includes/Block.php
includes/Title.php

index 1d98a29..3f00a51 100644 (file)
@@ -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 );
+               } );
        }
 
        /**
index 6acffa0..fda790f 100644 (file)
@@ -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
+                       );
+               } );
        }
 
        /**