MediaWiki REL1_33
EnqueueJob.php
Go to the documentation of this file.
1<?php
35final class EnqueueJob extends Job {
43 parent::__construct( 'enqueue', $title, $params );
44 }
45
50 public static function newFromLocalJobs( $jobs ) {
51 $jobs = is_array( $jobs ) ? $jobs : [ $jobs ];
52
54 WikiMap::getCurrentWikiDbDomain()->getId() => $jobs
55 ] );
56 }
57
62 public static function newFromJobsByDomain( array $jobsByDomain ) {
63 $deduplicate = true;
64
65 $jobMapsByDomain = [];
66 foreach ( $jobsByDomain as $domain => $jobs ) {
67 $jobMapsByDomain[$domain] = [];
68 foreach ( $jobs as $job ) {
69 if ( $job instanceof JobSpecification ) {
70 $jobMapsByDomain[$domain][] = $job->toSerializableArray();
71 } else {
72 throw new InvalidArgumentException( "Jobs must be of type JobSpecification." );
73 }
74 $deduplicate = $deduplicate && $job->ignoreDuplicates();
75 }
76 }
77
78 $eJob = new self(
79 Title::makeTitle( NS_SPECIAL, 'Badtitle/' . __CLASS__ ),
80 [ 'jobsByDomain' => $jobMapsByDomain ]
81 );
82 // If *all* jobs to be pushed are to be de-duplicated (a common case), then
83 // de-duplicate this whole job itself to avoid build up in high traffic cases
84 $eJob->removeDuplicates = $deduplicate;
85
86 return $eJob;
87 }
88
94 public static function newFromJobsByWiki( array $jobsByWiki ) {
95 return self::newFromJobsByDomain( $jobsByWiki );
96 }
97
98 public function run() {
99 $jobsByDomain = $this->params['jobsByDomain'] ?? $this->params['jobsByWiki']; // b/c
100
101 foreach ( $jobsByDomain as $domain => $jobMaps ) {
102 $jobSpecs = [];
103 foreach ( $jobMaps as $jobMap ) {
104 $jobSpecs[] = JobSpecification::newFromArray( $jobMap );
105 }
106 JobQueueGroup::singleton( $domain )->push( $jobSpecs );
107 }
108
109 return true;
110 }
111}
Router job that takes jobs and enqueues them to their proper queues.
static newFromJobsByWiki(array $jobsByWiki)
__construct(Title $title, array $params)
Callers should use the factory methods instead.
run()
Run the job.
static newFromLocalJobs( $jobs)
static newFromJobsByDomain(array $jobsByDomain)
Job queue task description base code.
static newFromArray(array $map)
Class to both describe a background job and handle jobs.
Definition Job.php:30
Title $title
Definition Job.php:41
array $params
Array of job parameters.
Definition Job.php:35
Represents a title within MediaWiki.
Definition Title.php:40
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
const NS_SPECIAL
Definition Defines.php:62
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
if(count( $args)< 1) $job