From: Aaron Schulz Date: Fri, 11 Jan 2013 23:00:20 +0000 (-0800) Subject: [JobQueue] Added push() convenience wrapper function. X-Git-Tag: 1.31.0-rc.0~21016 X-Git-Url: http://git.cyclocoop.org/fichier?a=commitdiff_plain;h=9d0e8dc2dc03f4466e75137ea65372875d1d7d79;p=lhc%2Fweb%2Fwiklou.git [JobQueue] Added push() convenience wrapper function. Change-Id: I4040b06fb286c28c8df733efb9bdd42bd7335f16 --- 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; } }