[JobQueue] Added push() convenience wrapper function.
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 11 Jan 2013 23:00:20 +0000 (15:00 -0800)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 17 Jan 2013 07:31:56 +0000 (07:31 +0000)
Change-Id: I4040b06fb286c28c8df733efb9bdd42bd7335f16

includes/job/JobQueue.php
includes/job/JobQueueGroup.php

index 6ec9b19..17f6648 100644 (file)
@@ -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 ) {
index eaa68d5..cf0215b 100644 (file)
@@ -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;
                        }
                }