From 9d0e8dc2dc03f4466e75137ea65372875d1d7d79 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Fri, 11 Jan 2013 15:00:20 -0800 Subject: [PATCH] [JobQueue] Added push() convenience wrapper function. Change-Id: I4040b06fb286c28c8df733efb9bdd42bd7335f16 --- includes/job/JobQueue.php | 17 ++++++++++++++++- includes/job/JobQueueGroup.php | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/includes/job/JobQueue.php b/includes/job/JobQueue.php index 6ec9b1925e..17f6648fc2 100644 --- a/includes/job/JobQueue.php +++ b/includes/job/JobQueue.php @@ -152,6 +152,21 @@ abstract class JobQueue { */ abstract protected function doGetAcquiredCount(); + /** + * Push a single jobs into the queue. + * This does not require $wgJobClasses to be set for the given job type. + * + * @param $jobs Job|Array + * @param $flags integer Bitfield (supports JobQueue::QoS_Atomic) + * @throws MWException + * @return bool Returns false on failure + */ + final public function push( $jobs, $flags = 0 ) { + $jobs = is_array( $jobs ) ? $jobs : array( $jobs ); + + return $this->batchPush( $jobs, $flags ); + } + /** * Push a batch of jobs into the queue. * This does not require $wgJobClasses to be set for the given job type. @@ -159,7 +174,7 @@ abstract class JobQueue { * @param $jobs array List of Jobs * @param $flags integer Bitfield (supports JobQueue::QoS_Atomic) * @throws MWException - * @return bool + * @return bool Returns false on failure */ final public function batchPush( array $jobs, $flags = 0 ) { foreach ( $jobs as $job ) { diff --git a/includes/job/JobQueueGroup.php b/includes/job/JobQueueGroup.php index eaa68d5c38..cf0215b8bf 100644 --- a/includes/job/JobQueueGroup.php +++ b/includes/job/JobQueueGroup.php @@ -111,7 +111,7 @@ class JobQueueGroup { $ok = true; foreach ( $jobsByType as $type => $jobs ) { - if ( !$this->get( $type )->batchPush( $jobs ) ) { + if ( !$this->get( $type )->push( $jobs ) ) { $ok = false; } } -- 2.20.1