X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FWiki.php;h=d78d7cb6567bca1d1895cd6d0c46071fb74deefd;hb=ceccc158847c173d5a1c2b388334268222832e4a;hp=fb46d80d43c58f29d51d1fa4fa19e1a14e32a2ef;hpb=830eb262fe76ef3ad49f91daad5e152af8ce9bc4;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Wiki.php b/includes/Wiki.php index fb46d80d43..d78d7cb656 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -621,7 +621,7 @@ class MediaWiki { * the socket once it's done. */ protected function triggerJobs() { - global $wgJobRunRate, $wgServer, $wgScriptPath, $wgScriptExtension; + global $wgJobRunRate, $wgServer, $wgScriptPath, $wgScriptExtension, $wgEnableAPI; if ( $wgJobRunRate <= 0 || wfReadOnly() ) { return; @@ -643,16 +643,26 @@ class MediaWiki { 'tasks' => 'jobs', 'maxjobs' => $n, 'sigexpiry' => time() + 5 ); $query['signature'] = ApiRunJobs::getQuerySignature( $query ); + if ( !$wgEnableAPI ) { + // Fall back to running the job here while the user waits + ApiRunJobs::executeJobs( $n ); + return; + } + $errno = $errstr = null; $info = wfParseUrl( $wgServer ); + wfSuppressWarnings(); $sock = fsockopen( $info['host'], isset( $info['port'] ) ? $info['port'] : 80, $errno, $errstr ); + wfRestoreWarnings(); if ( !$sock ) { wfDebugLog( 'runJobs', "Failed to start cron API (socket error $errno): $errstr\n" ); + // Fall back to running the job here while the user waits + ApiRunJobs::executeJobs( $n ); return; } @@ -661,7 +671,7 @@ class MediaWiki { wfDebugLog( 'runJobs', "Running $n job(s) via '$url'\n" ); // Send a cron API request to be performed in the background. - // Give up if this takes to long to send (which should be rare). + // Give up if this takes too long to send (which should be rare). stream_set_timeout( $sock, 1 ); $bytes = fwrite( $sock, $req ); if ( $bytes !== strlen( $req ) ) { @@ -670,7 +680,7 @@ class MediaWiki { // Do not wait for the response (the script should handle client aborts). // Make sure that we don't close before that script reaches ignore_user_abort(). $status = fgets( $sock ); - if ( !preg_match( '#^HTTP/\d\.\d 204 #', $status ) ) { + if ( !preg_match( '#^HTTP/\d\.\d 202 #', $status ) ) { wfDebugLog( 'runJobs', "Failed to start cron API: received '$status'\n" ); } }