Merge "Add isCurrentWikiId()/isCurrentWikiDomain()/getCurrentWikiDomain() to WikiMap"
[lhc/web/wiklou.git] / includes / jobqueue / JobQueueGroup.php
index dc0b249..3d88089 100644 (file)
@@ -43,9 +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
 
@@ -105,11 +102,7 @@ class JobQueueGroup {
                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;
@@ -203,7 +196,7 @@ class JobQueueGroup {
                // 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 ) );
        }
 
        /**
@@ -211,17 +204,10 @@ class JobQueueGroup {
         *
         * @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' );
        }
 
        /**
@@ -464,12 +450,4 @@ class JobQueueGroup {
                        }
                }
        }
-
-       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." );
-               }
-       }
 }