Merge "Add css $classes variable to the OldChangesListRecentChangesLine hook"
[lhc/web/wiklou.git] / includes / job / JobQueueGroup.php
index 4ebd531..10fe51c 100644 (file)
@@ -25,7 +25,7 @@
  * Class to handle enqueueing of background jobs
  *
  * @ingroup JobQueue
- * @since 1.20
+ * @since 1.21
  */
 class JobQueueGroup {
        /** @var Array */
@@ -76,6 +76,7 @@ class JobQueueGroup {
         * 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 ) {
@@ -132,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
         *
@@ -153,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;
+       }
 }