Merge "Create JobQueueEnqueueUpdate class to call JobQueueGroup::pushLazyJobs()"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sun, 28 Oct 2018 23:10:53 +0000 (23:10 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sun, 28 Oct 2018 23:10:53 +0000 (23:10 +0000)
1  2 
autoload.php
includes/MediaWiki.php
includes/jobqueue/JobQueueGroup.php

diff --combined autoload.php
@@@ -706,6 -706,7 +706,7 @@@ $wgAutoloadLocalClasses = 
        'JobQueueAggregatorRedis' => __DIR__ . '/includes/jobqueue/aggregator/JobQueueAggregatorRedis.php',
        'JobQueueConnectionError' => __DIR__ . '/includes/jobqueue/JobQueue.php',
        'JobQueueDB' => __DIR__ . '/includes/jobqueue/JobQueueDB.php',
+       'JobQueueEnqueueUpdate' => __DIR__ . '/includes/deferred/JobQueueEnqueueUpdate.php',
        'JobQueueError' => __DIR__ . '/includes/jobqueue/JobQueue.php',
        'JobQueueFederated' => __DIR__ . '/includes/jobqueue/JobQueueFederated.php',
        'JobQueueGroup' => __DIR__ . '/includes/jobqueue/JobQueueGroup.php',
        'UserBlockedError' => __DIR__ . '/includes/exception/UserBlockedError.php',
        'UserCache' => __DIR__ . '/includes/cache/UserCache.php',
        'UserDupes' => __DIR__ . '/maintenance/userDupes.inc',
 +      'UserEditCountUpdate' => __DIR__ . '/includes/deferred/UserEditCountUpdate.php',
        'UserGroupExpiryJob' => __DIR__ . '/includes/jobqueue/jobs/UserGroupExpiryJob.php',
        'UserGroupMembership' => __DIR__ . '/includes/user/UserGroupMembership.php',
        'UserMailer' => __DIR__ . '/includes/mail/UserMailer.php',
diff --combined includes/MediaWiki.php
@@@ -43,7 -43,7 +43,7 @@@ class MediaWiki 
        private $config;
  
        /**
 -       * @var String Cache what action this request is
 +       * @var string Cache what action this request is
         */
        private $action;
  
         * @since 1.26
         */
        public function doPostOutputShutdown( $mode = 'normal' ) {
 +              // Record backend request timing
 +              $timing = $this->context->getTiming();
 +              $timing->mark( 'requestShutdown' );
 +
                // Perform the last synchronous operations...
                try {
 -                      // Record backend request timing
 -                      $timing = $this->context->getTiming();
 -                      $timing->mark( 'requestShutdown' );
                        // Show visible profiling data if enabled (which cannot be post-send)
                        Profiler::instance()->logDataPageOutputOnly();
                } catch ( Exception $e ) {
                        __METHOD__
                );
  
-               // Important: this must be the last deferred update added (T100085, T154425)
-               DeferredUpdates::addCallableUpdate( [ JobQueueGroup::class, 'pushLazyJobs' ] );
                // Do any deferred jobs; preferring to run them now if a client will not wait on them
                DeferredUpdates::doUpdates( $blocksHttpClient ? 'enqueue' : 'run' );
  
@@@ -43,9 -43,6 +43,6 @@@ class JobQueueGroup 
        /** @var array Map of (bucket => (queue => JobQueue, types => list of types) */
        protected $coalescedQueues;
  
-       /** @var Job[] */
-       protected $bufferedJobs = [];
        const TYPE_DEFAULT = 1; // integer; jobs popped by default
        const TYPE_ANY = 2; // integer; any job
  
                global $wgJobTypeConf;
  
                $conf = [ 'wiki' => $this->wiki, 'type' => $type ];
 -              if ( isset( $wgJobTypeConf[$type] ) ) {
 -                      $conf = $conf + $wgJobTypeConf[$type];
 -              } else {
 -                      $conf = $conf + $wgJobTypeConf['default'];
 -              }
 +              $conf += $wgJobTypeConf[$type] ?? $wgJobTypeConf['default'];
                $conf['aggregator'] = JobQueueAggregator::singleton();
                if ( !isset( $conf['readOnlyReason'] ) ) {
                        $conf['readOnlyReason'] = $this->readOnlyReason;
                // Throw errors now instead of on push(), when other jobs may be buffered
                $this->assertValidJobs( $jobs );
  
-               $this->bufferedJobs = array_merge( $this->bufferedJobs, $jobs );
+               DeferredUpdates::addUpdate( new JobQueueEnqueueUpdate( $this->wiki, $jobs ) );
        }
  
        /**
         *
         * @return void
         * @since 1.26
+        * @deprecated Since 1.33 Not needed anymore
         */
        public static function pushLazyJobs() {
-               foreach ( self::$instances as $group ) {
-                       try {
-                               $group->push( $group->bufferedJobs );
-                               $group->bufferedJobs = [];
-                       } catch ( Exception $e ) {
-                               // Get in as many jobs as possible and let other post-send updates happen
-                               MWExceptionHandler::logException( $e );
-                       }
-               }
+               wfDeprecated( __METHOD__, '1.33' );
        }
  
        /**
                        }
                }
        }
-       function __destruct() {
-               $n = count( $this->bufferedJobs );
-               if ( $n > 0 ) {
-                       $type = implode( ', ', array_unique( array_map( 'get_class', $this->bufferedJobs ) ) );
-                       trigger_error( __METHOD__ . ": $n buffered job(s) of type(s) $type never inserted." );
-               }
-       }
  }