MediaWiki REL1_28
Go to the documentation of this file.
36final class EnqueueJob extends Job {
44 parent::__construct( 'enqueue', $title, $params );
45 }
51 public static function newFromLocalJobs( $jobs ) {
52 $jobs = is_array( $jobs ) ? $jobs : [ $jobs ];
54 return self::newFromJobsByWiki( [ wfWikiID() => $jobs ] );
55 }
61 public static function newFromJobsByWiki( array $jobsByWiki ) {
62 $deduplicate = true;
64 $jobMapsByWiki = [];
65 foreach ( $jobsByWiki as $wiki => $jobs ) {
66 $jobMapsByWiki[$wiki] = [];
67 foreach ( $jobs as $job ) {
68 if ( $job instanceof JobSpecification ) {
69 $jobMapsByWiki[$wiki][] = $job->toSerializableArray();
70 } else {
71 throw new InvalidArgumentException( "Jobs must be of type JobSpecification." );
72 }
73 $deduplicate = $deduplicate && $job->ignoreDuplicates();
74 }
75 }
77 $eJob = new self(
78 Title::makeTitle( NS_SPECIAL, 'Badtitle/' . __CLASS__ ),
79 [ 'jobsByWiki' => $jobMapsByWiki ]
80 );
81 // If *all* jobs to be pushed are to be de-duplicated (a common case), then
82 // de-duplicate this whole job itself to avoid build up in high traffic cases
83 $eJob->removeDuplicates = $deduplicate;
85 return $eJob;
86 }
88 public function run() {
89 foreach ( $this->params['jobsByWiki'] as $wiki => $jobMaps ) {
90 $jobSpecs = [];
91 foreach ( $jobMaps as $jobMap ) {
92 $jobSpecs[] = JobSpecification::newFromArray( $jobMap );
93 }
94 JobQueueGroup::singleton( $wiki )->push( $jobSpecs );
95 }
97 return true;
98 }
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
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 the job.
static newFromLocalJobs( $jobs)
static singleton( $wiki=false)
Job queue task description base code.
static newFromArray(array $map)
Class to both describe a background job and handle jobs.
Definition Job.php:31
Title $title
Definition Job.php:42
array $params
Array of job parameters.
Definition Job.php:36
Represents a title within MediaWiki.
Definition Title.php:36
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
Definition Defines.php:45
the array() calling protocol came about after MediaWiki 1.4rc1.
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
if(count( $args)< 1) $job