From: Nik Everett Date: Fri, 7 Mar 2014 15:39:21 +0000 (-0500) Subject: Have ApiRunJobs run periodic tasks X-Git-Tag: 1.31.0-rc.0~16703 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=142db358fc57bcdb452f5e8ef5071b25c87f6f36;p=lhc%2Fweb%2Fwiklou.git Have ApiRunJobs run periodic tasks Without this apirunjobs can't handle delayed jobs. Small inline comment updates as well. Change-Id: I85ba0ac99eaebc16eaa7e2eb7019546241f3149c --- diff --git a/includes/Wiki.php b/includes/Wiki.php index 5c67e5f8e6..d78d7cb656 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -644,7 +644,8 @@ class MediaWiki { $query['signature'] = ApiRunJobs::getQuerySignature( $query ); if ( !$wgEnableAPI ) { - ApiRunJobs::executeJobs( $n ); // slow fallback + // Fall back to running the job here while the user waits + ApiRunJobs::executeJobs( $n ); return; } @@ -660,7 +661,8 @@ class MediaWiki { wfRestoreWarnings(); if ( !$sock ) { wfDebugLog( 'runJobs', "Failed to start cron API (socket error $errno): $errstr\n" ); - ApiRunJobs::executeJobs( $n ); // slow fallback + // Fall back to running the job here while the user waits + ApiRunJobs::executeJobs( $n ); return; } diff --git a/includes/api/ApiRunJobs.php b/includes/api/ApiRunJobs.php index e16dc5d298..e23aaf548a 100644 --- a/includes/api/ApiRunJobs.php +++ b/includes/api/ApiRunJobs.php @@ -94,10 +94,14 @@ class ApiRunJobs extends ApiBase { return; } try { - // Fallback to running the jobs here while the user waits $group = JobQueueGroup::singleton(); + $count = $group->executeReadyPeriodicTasks(); + if ( $count > 0 ) { + wfDebugLog( 'jobqueue', "Executed $count periodic queue task(s)." ); + } + do { - $job = $group->pop( JobQueueGroup::USE_CACHE ); // job from any queue + $job = $group->pop( JobQueueGroup::TYPE_DEFAULT, JobQueueGroup::USE_CACHE ); // job from any queue if ( $job ) { $output = $job->toString() . "\n"; $t = - microtime( true );