MediaWiki  1.34.0
JobQueueEnqueueUpdate.php
Go to the documentation of this file.
1 <?php
23 use Wikimedia\Assert\Assert;
24 
33  private $jobsByDomain;
34 
39  public function __construct( $domain, array $jobs ) {
40  $this->jobsByDomain[$domain] = $jobs;
41  }
42 
43  public function merge( MergeableUpdate $update ) {
45  Assert::parameterType( __CLASS__, $update, '$update' );
46  '@phan-var self $update';
47 
48  foreach ( $update->jobsByDomain as $domain => $jobs ) {
49  $this->jobsByDomain[$domain] = $this->jobsByDomain[$domain] ?? [];
50  $this->jobsByDomain[$domain] = array_merge( $this->jobsByDomain[$domain], $jobs );
51  }
52  }
53 
54  public function doUpdate() {
55  foreach ( $this->jobsByDomain as $domain => $jobs ) {
56  $group = JobQueueGroup::singleton( $domain );
57  try {
58  $group->push( $jobs );
59  } catch ( Exception $e ) {
60  // Get in as many jobs as possible and let other post-send updates happen
62  }
63  }
64  }
65 }
JobQueueEnqueueUpdate\doUpdate
doUpdate()
Perform the actual work.
Definition: JobQueueEnqueueUpdate.php:54
JobQueueEnqueueUpdate
Enqueue lazy-pushed jobs that have accumulated from JobQueueGroup.
Definition: JobQueueEnqueueUpdate.php:31
MergeableUpdate
Interface that deferrable updates can implement to signal that updates can be combined.
Definition: MergeableUpdate.php:18
JobQueueEnqueueUpdate\__construct
__construct( $domain, array $jobs)
Definition: JobQueueEnqueueUpdate.php:39
JobQueueEnqueueUpdate\$jobsByDomain
array[] $jobsByDomain
Map of (domain ID => IJobSpecification[])
Definition: JobQueueEnqueueUpdate.php:33
JobQueueGroup\singleton
static singleton( $domain=false)
Definition: JobQueueGroup.php:70
JobQueueEnqueueUpdate\merge
merge(MergeableUpdate $update)
Merge this update with $update.
Definition: JobQueueEnqueueUpdate.php:43
DeferrableUpdate
Interface that deferrable updates should implement.
Definition: DeferrableUpdate.php:9
MWExceptionHandler\logException
static logException( $e, $catcher=self::CAUGHT_BY_OTHER, $extraData=[])
Log an exception to the exception log (if enabled).
Definition: MWExceptionHandler.php:691