Revert "Made JobQueueFederated no longer need "checkDelay" for delaying"
[lhc/web/wiklou.git] / includes / jobqueue / JobQueue.php
index 53fcaee..1a730d3 100644 (file)
@@ -49,6 +49,8 @@ abstract class JobQueue {
 
        /** @var BagOStuff */
        protected $dupCache;
+       /** @var JobQueueAggregator */
+       protected $aggr;
 
        const QOS_ATOMIC = 1; // integer; "all-or-nothing" job insertions
 
@@ -76,6 +78,9 @@ abstract class JobQueue {
                        throw new MWException( __CLASS__ . " does not support delayed jobs." );
                }
                $this->dupCache = wfGetCache( CACHE_ANYTHING );
+               $this->aggr = isset( $params['aggregator'] )
+                       ? $params['aggregator']
+                       : new JobQueueAggregatorNull( array() );
        }
 
        /**
@@ -298,7 +303,8 @@ abstract class JobQueue {
         * @throws JobQueueError
         */
        final public function push( $jobs, $flags = 0 ) {
-               $this->batchPush( is_array( $jobs ) ? $jobs : array( $jobs ), $flags );
+               $jobs = is_array( $jobs ) ? $jobs : array( $jobs );
+               $this->batchPush( $jobs, $flags );
        }
 
        /**
@@ -327,6 +333,7 @@ abstract class JobQueue {
                }
 
                $this->doBatchPush( $jobs, $flags );
+               $this->aggr->notifyQueueNonEmpty( $this->wiki, $this->type );
        }
 
        /**
@@ -356,6 +363,10 @@ abstract class JobQueue {
 
                $job = $this->doPop();
 
+               if ( !$job ) {
+                       $this->aggr->notifyQueueEmpty( $this->wiki, $this->type );
+               }
+
                // Flag this job as an old duplicate based on its "root" job...
                try {
                        if ( $job && $this->isRootJobOldDuplicate( $job ) ) {