Avoid making a derivative request to Special:RunJobs when the job queue is empty
[lhc/web/wiklou.git] / includes / Wiki.php
index 6cf718c..fbafba8 100644 (file)
@@ -624,7 +624,7 @@ class MediaWiki {
         * the socket once it's done.
         */
        protected function triggerJobs() {
-               global $wgJobRunRate, $wgServer;
+               global $wgJobRunRate, $wgServer, $wgRunJobsAsync;
 
                if ( $wgJobRunRate <= 0 || wfReadOnly() ) {
                        return;
@@ -644,6 +644,17 @@ class MediaWiki {
                        $n = intval( $wgJobRunRate );
                }
 
+               if ( !$wgRunJobsAsync ) {
+                       // If running jobs asynchronously has been disabled, run the job here
+                       // while the user waits
+                       SpecialRunJobs::executeJobs( $n );
+                       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 );