MediaWiki  master
JobQueueEnqueueUpdate.php
Go to the documentation of this file.
1 <?php
25 use Wikimedia\Assert\Assert;
26 
35  private $jobsByDomain;
36 
38  private $jobQueueGroupFactory;
39 
44  public function __construct( string $domain, array $jobs ) {
45  $this->jobsByDomain[$domain] = $jobs;
46  // TODO Inject services, when DeferredUpdates supports DI
47  $this->jobQueueGroupFactory = MediaWikiServices::getInstance()->getJobQueueGroupFactory();
48  }
49 
51  public function merge( MergeableUpdate $update ) {
53  Assert::parameterType( __CLASS__, $update, '$update' );
54  '@phan-var self $update';
55 
56  foreach ( $update->jobsByDomain as $domain => $jobs ) {
57  $this->jobsByDomain[$domain] = array_merge(
58  $this->jobsByDomain[$domain] ?? [],
59  $jobs
60  );
61  }
62  }
63 
65  public function doUpdate() {
66  foreach ( $this->jobsByDomain as $domain => $jobs ) {
67  $group = $this->jobQueueGroupFactory->makeJobQueueGroup( $domain );
68  try {
69  $group->push( $jobs );
70  } catch ( Throwable $e ) {
71  // Get in as many jobs as possible and let other post-send updates happen
73  }
74  }
75  }
76 }
Enqueue lazy-pushed jobs that have accumulated from JobQueueGroup.
__construct(string $domain, array $jobs)
doUpdate()
Perform the actual work.
merge(MergeableUpdate $update)
Merge this enqueued update with a new MergeableUpdate of the same qualified class name....
static logException(Throwable $e, $catcher=self::CAUGHT_BY_OTHER, $extraData=[])
Log a throwable to the exception log (if enabled).
Class to construct JobQueueGroups.
Service locator for MediaWiki core services.
Interface that deferrable updates should implement.
Interface that deferrable updates can implement to signal that updates can be combined.