*
* @param Job|array $jobs A single Job or a list of Jobs
* @throws MWException
- * @return bool
+ * @return void
*/
public function push( $jobs ) {
$jobs = is_array( $jobs ) ? $jobs : array( $jobs );
if ( !count( $jobs ) ) {
- return true;
+ return;
}
$jobsByType = array(); // (job type => list of jobs)
}
}
- $ok = true;
foreach ( $jobsByType as $type => $jobs ) {
- if ( $this->get( $type )->push( $jobs ) ) {
- JobQueueAggregator::singleton()->notifyQueueNonEmpty( $this->wiki, $type );
- } else {
- $ok = false;
- }
+ $this->get( $type )->push( $jobs );
+ JobQueueAggregator::singleton()->notifyQueueNonEmpty( $this->wiki, $type );
}
if ( $this->cache->has( 'queues-ready', 'list' ) ) {
$this->cache->clear( 'queues-ready' );
}
}
-
- return $ok;
}
/**
return array_diff( $this->getQueueTypes(), $wgJobTypesExcludedFromDefaultQueue );
}
+ /**
+ * Check if there are any queues with jobs (this is cached)
+ *
+ * @param int $type JobQueueGroup::TYPE_* constant
+ * @return bool
+ * @since 1.23
+ */
+ public function queuesHaveJobs( $type = self::TYPE_ANY ) {
+ global $wgMemc;
+
+ $key = wfMemcKey( 'jobqueue', 'queueshavejobs', $type );
+
+ $value = $wgMemc->get( $key );
+ if ( $value === false ) {
+ $queues = $this->getQueuesWithJobs();
+ if ( $type == self::TYPE_DEFAULT ) {
+ $queues = array_intersect( $queues, $this->getDefaultQueueTypes() );
+ }
+ $value = count( $queues ) ? 'true' : 'false';
+ $wgMemc->add( $key, $value, 15 );
+ }
+
+ return ( $value === 'true' );
+ }
+
/**
* Get the list of job types that have non-empty queues
*
}
/**
- * @param $name string
+ * @param string $name
* @return mixed
*/
private function getCachedConfigVar( $name ) {