X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fjob%2FJobQueueGroup.php;h=10fe51c740fb05b49fcbedbd3bb53107df34cbc2;hb=2e07c7de680ccbcdb41011bca125e1976b5532ff;hp=69bcf011bea3617f089c48fe2a1db81dc57cb33e;hpb=43750ed984b5c843aae935514b18ffb98a1079af;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/job/JobQueueGroup.php b/includes/job/JobQueueGroup.php index 69bcf011be..10fe51c740 100644 --- a/includes/job/JobQueueGroup.php +++ b/includes/job/JobQueueGroup.php @@ -25,7 +25,7 @@ * Class to handle enqueueing of background jobs * * @ingroup JobQueue - * @since 1.20 + * @since 1.21 */ class JobQueueGroup { /** @var Array */ @@ -62,24 +62,21 @@ class JobQueueGroup { public function get( $type ) { global $wgJobTypeConf; - $conf = false; + $conf = array( 'wiki' => $this->wiki, 'type' => $type ); if ( isset( $wgJobTypeConf[$type] ) ) { - $conf = $wgJobTypeConf[$type]; + $conf = $conf + $wgJobTypeConf[$type]; } else { - $conf = $wgJobTypeConf['default']; + $conf = $conf + $wgJobTypeConf['default']; } - return JobQueue::factory( array( - 'class' => $conf['class'], - 'wiki' => $this->wiki, - 'type' => $type, - ) ); + return JobQueue::factory( $conf ); } /** * Insert jobs into the respective queues of with the belong * * @param $jobs Job|array A single Job or a list of Jobs + * @throws MWException * @return bool */ public function push( $jobs ) { @@ -136,6 +133,17 @@ class JobQueueGroup { return $this->get( $job->getType() )->ack( $job ); } + /** + * Register the "root job" of a given job into the queue for de-duplication. + * This should only be called right *after* all the new jobs have been inserted. + * + * @param $job Job + * @return bool + */ + public function deduplicateRootJob( Job $job ) { + return $this->get( $job->getType() )->deduplicateRootJob( $job ); + } + /** * Get the list of queue types * @@ -157,4 +165,17 @@ class JobQueueGroup { return array_diff( $this->getQueueTypes(), $wgJobTypesExcludedFromDefaultQueue ); } + + /** + * @return Array List of job types that have non-empty queues + */ + public function getQueuesWithJobs() { + $types = array(); + foreach ( $this->getQueueTypes() as $type ) { + if ( !$this->get( $type )->isEmpty() ) { + $types[] = $type; + } + } + return $types; + } }