return;
}
+ if ( !JobQueueGroup::singleton()->queuesHaveJobs( JobQueueGroup::TYPE_DEFAULT ) ) {
+ return; // do not send request if there are probably no jobs
+ }
+
$query = array( 'title' => 'Special:RunJobs',
'tasks' => 'jobs', 'maxjobs' => $n, 'sigexpiry' => time() + 5 );
$query['signature'] = SpecialRunJobs::getQuerySignature( $query );
return array_diff( $this->getQueueTypes(), $wgJobTypesExcludedFromDefaultQueue );
}
+ /**
+ * Check if there are any queues with jobs (this is cached)
+ *
+ * @param integer $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
*