X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FWiki.php;h=2fd12d5e84e495b33965c054ea2a7834990279a2;hb=59f06176c3598c9ed46ed4f08317a656f0e82b62;hp=f8f699c91cfb8b05a34d1ffa682d10e262d0d5ca;hpb=4f741418fcb0a85f1ccfa3a72e5faa34259b8e53;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Wiki.php b/includes/Wiki.php index f8f699c91c..2fd12d5e84 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -126,7 +126,7 @@ class MediaWiki { * @return Title */ public function getTitle() { - if( $this->context->getTitle() === null ) { + if ( $this->context->getTitle() === null ) { $this->context->setTitle( $this->parseTitle() ); } return $this->context->getTitle(); @@ -480,7 +480,7 @@ class MediaWiki { $resp->header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) ); $resp->header( 'X-Database-Lag: ' . intval( $lag ) ); $resp->header( 'Content-Type: text/plain' ); - if( $wgShowHostnames ) { + if ( $wgShowHostnames ) { echo "Waiting for $host: $lag seconds lagged\n"; } else { echo "Waiting for a database server: $lag seconds lagged\n"; @@ -599,7 +599,7 @@ class MediaWiki { * Do a job from the job queue */ private function doJobs() { - global $wgJobRunRate; + global $wgJobRunRate, $wgPhpCli, $IP; if ( $wgJobRunRate <= 0 || wfReadOnly() ) { return; @@ -615,23 +615,36 @@ class MediaWiki { $n = intval( $wgJobRunRate ); } - $group = JobQueueGroup::singleton(); - do { - $job = $group->pop( JobQueueGroup::USE_CACHE ); // job from any queue - if ( $job ) { - $output = $job->toString() . "\n"; - $t = - microtime( true ); - $success = $job->run(); - $group->ack( $job ); // done - $t += microtime( true ); - $t = round( $t * 1000 ); - if ( !$success ) { - $output .= "Error: " . $job->getLastError() . ", Time: $t ms\n"; - } else { - $output .= "Success, Time: $t ms\n"; + if ( !wfShellExecDisabled() && is_executable( $wgPhpCli ) ) { + // Start a background process to run some of the jobs. + // This will be asynchronous on *nix though not on Windows. + wfProfileIn( __METHOD__ . '-exec' ); + $retVal = 1; + $cmd = wfShellWikiCmd( "$IP/maintenance/runJobs.php", array( '--maxjobs', $n ) ); + wfShellExec( "$cmd &", $retVal ); + wfProfileOut( __METHOD__ . '-exec' ); + } else { + // Fallback to running the jobs here while the user waits + $group = JobQueueGroup::singleton(); + do { + $job = $group->pop( JobQueueGroup::USE_CACHE ); // job from any queue + if ( $job ) { + $output = $job->toString() . "\n"; + $t = - microtime( true ); + wfProfileIn( __METHOD__ . '-' . get_class( $job ) ); + $success = $job->run(); + wfProfileOut( __METHOD__ . '-' . get_class( $job ) ); + $group->ack( $job ); // done + $t += microtime( true ); + $t = round( $t * 1000 ); + if ( $success === false ) { + $output .= "Error: " . $job->getLastError() . ", Time: $t ms\n"; + } else { + $output .= "Success, Time: $t ms\n"; + } + wfDebugLog( 'jobqueue', $output ); } - wfDebugLog( 'jobqueue', $output ); - } - } while ( --$n && $job ); + } while ( --$n && $job ); + } } }