MediaWiki REL1_33
EnqueueJob.php
Go to the documentation of this file.
1<?php
35final class EnqueueJob extends Job {
42 function __construct( Title $title, array $params ) {
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}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
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
array $params
Array of job parameters.
Definition Job.php:35
Represents a title within MediaWiki.
Definition Title.php:40
const NS_SPECIAL
Definition Defines.php:62
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