Remove $recursionGuard var from tryOpportunisticExecute()
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 1 Sep 2016 17:01:25 +0000 (10:01 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Thu, 1 Sep 2016 22:56:45 +0000 (22:56 +0000)
Aside from there being no idle callback setting here, the
old addUpdate() code that runs updates allows nesting updates.
Make this support that for a few transitional commits. It will
be changed later to simply order the sub-updates after their
parent updates, keeping both outer scope for all updates and
locality of related updates.

Change-Id: I0ad4e9713a7893b981b7bb013e9db803eed663b2

includes/deferred/DeferredUpdates.php

index 5622f95..48f1e8e 100644 (file)
@@ -195,29 +195,19 @@ class DeferredUpdates {
         * @since 1.28
         */
        public static function tryOpportunisticExecute( $mode = 'run' ) {
-               static $recursionGuard = false;
-               if ( $recursionGuard ) {
-                       return false; // COMMITs trigger inside update loop and inside some updates
+               if ( !self::getBusyDbConnections() ) {
+                       self::doUpdates( $mode );
+                       return true;
                }
 
-               try {
-                       $recursionGuard = true;
-                       if ( !self::getBusyDbConnections() ) {
-                               self::doUpdates( $mode );
-                               return true;
-                       }
-
-                       if ( self::pendingUpdatesCount() >= self::BIG_QUEUE_SIZE ) {
-                               // If we cannot run the updates with outer transaction context, try to
-                               // at least enqueue all the updates that support queueing to job queue
-                               self::$preSendUpdates = self::enqueueUpdates( self::$preSendUpdates );
-                               self::$postSendUpdates = self::enqueueUpdates( self::$postSendUpdates );
-                       }
-
-                       return !self::pendingUpdatesCount();
-               } finally {
-                       $recursionGuard = false;
+               if ( self::pendingUpdatesCount() >= self::BIG_QUEUE_SIZE ) {
+                       // If we cannot run the updates with outer transaction context, try to
+                       // at least enqueue all the updates that support queueing to job queue
+                       self::$preSendUpdates = self::enqueueUpdates( self::$preSendUpdates );
+                       self::$postSendUpdates = self::enqueueUpdates( self::$postSendUpdates );
                }
+
+               return !self::pendingUpdatesCount();
        }
 
        /**