Made pushLazyJobs() handle all queue groups
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 19 May 2015 02:06:49 +0000 (19:06 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Tue, 19 May 2015 02:12:28 +0000 (02:12 +0000)
* This avoids __destruct() warnings
* Also remove push() code in __destruct() that just made
  more warnings since it's too late

Change-Id: I32a3cfabc94e36b9d2808b45d55209f3df46e47d

includes/MediaWiki.php
includes/jobqueue/JobQueueGroup.php

index 84001ff..62ab667 100644 (file)
@@ -459,7 +459,7 @@ class MediaWiki {
         */
        public function postSendUpdates() {
                try {
-                       JobQueueGroup::singleton()->pushLazyJobs();
+                       JobQueueGroup::pushLazyJobs();
                        $this->triggerJobs();
                        $this->restInPeace();
                } catch ( Exception $e ) {
@@ -626,7 +626,7 @@ class MediaWiki {
                DeferredUpdates::doUpdates( 'commit' );
 
                // Make sure any lazy jobs are pushed
-               JobQueueGroup::singleton()->pushLazyJobs();
+               JobQueueGroup::pushLazyJobs();
 
                // Log profiling data, e.g. in the database or UDP
                wfLogProfilingData();
index 72d2537..3d2393e 100644 (file)
@@ -28,7 +28,7 @@
  * @since 1.21
  */
 class JobQueueGroup {
-       /** @var array */
+       /** @var JobQueueGroup[] */
        protected static $instances = array();
 
        /** @var ProcessCacheLRU */
@@ -166,10 +166,11 @@ class JobQueueGroup {
         * @return void
         * @since 1.26
         */
-       public function pushLazyJobs() {
-               $this->push( $this->bufferedJobs );
-
-               $this->bufferedJobs = array();
+       public static function pushLazyJobs() {
+               foreach ( self::$instances as $group ) {
+                       $group->push( $group->bufferedJobs );
+                       $group->bufferedJobs = array();
+               }
        }
 
        /**
@@ -416,7 +417,6 @@ class JobQueueGroup {
                $n = count( $this->bufferedJobs );
                if ( $n > 0 ) {
                        trigger_error( __METHOD__ . ": $n buffered job(s) never inserted." );
-                       $this->pushLazyJobs(); // try to do it now
                }
        }
 }