Make DeferredUpdates::doUpdates always commit per task
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 8 Oct 2015 07:09:08 +0000 (00:09 -0700)
committerOri.livneh <ori@wikimedia.org>
Thu, 22 Oct 2015 01:27:08 +0000 (01:27 +0000)
* All callers are either using commit already or would be fine
  using it (e.g. Maintenance scripts and JobRunner that have
  no real transaction open).

Change-Id: I9f54b27619da6dac2cb63d255995aabc4ee78002

includes/MediaWiki.php
includes/deferred/DeferredUpdates.php
maintenance/doMaintenance.php

index 7ae7c35..676108c 100644 (file)
@@ -690,7 +690,7 @@ class MediaWiki {
                Profiler::instance()->getTransactionProfiler()->resetExpectations();
 
                // Do any deferred jobs
-               DeferredUpdates::doUpdates( 'commit', 'enqueue' );
+               DeferredUpdates::doUpdates( 'enqueue' );
 
                // Make sure any lazy jobs are pushed
                JobQueueGroup::pushLazyJobs();
index 8f8ed2e..0194a61 100644 (file)
@@ -94,11 +94,17 @@ class DeferredUpdates {
        /**
         * Do any deferred updates and clear the list
         *
-        * @param string $commit Set to 'commit' to commit after every update to
         * @param string $mode Use "enqueue" to use the job queue when possible [Default: run]
         *   prevent lock contention
+        * @param string $oldMode Unused
         */
-       public static function doUpdates( $commit = '', $mode = 'run' ) {
+       public static function doUpdates( $mode = 'run', $oldMode = '' ) {
+               // B/C for ( $commit, $mode ) args
+               $mode = $oldMode ?: $mode;
+               if ( $mode === 'commit' ) {
+                       $mode = 'run';
+               }
+
                $updates = self::$updates;
 
                while ( count( $updates ) ) {
@@ -121,9 +127,7 @@ class DeferredUpdates {
                        foreach ( $otherUpdates as $update ) {
                                try {
                                        $update->doUpdate();
-                                       if ( $commit === 'commit' ) {
-                                               wfGetLBFactory()->commitMasterChanges();
-                                       }
+                                       wfGetLBFactory()->commitMasterChanges();
                                } catch ( Exception $e ) {
                                        // We don't want exceptions thrown during deferred updates to
                                        // be reported to the user since the output is already sent.
index 4b9ad9c..e66b729 100644 (file)
@@ -106,7 +106,7 @@ $maintenance->execute();
 $maintenance->globals();
 
 // Perform deferred updates.
-DeferredUpdates::doUpdates( 'commit' );
+DeferredUpdates::doUpdates();
 
 // log profiling info
 wfLogProfilingData();