X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2FWiki.php;h=d4840cc22eeb7df3dfeac7dd3c0f071531b3f5e1;hb=21b7b27f0379cff1b06efa95d27fa88684b65c57;hp=e6ccbe5a40d15668dfda92cfb7641fb5e6cb4283;hpb=e34865144f3f21bb8b0ad4ba76d3d10490a73462;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Wiki.php b/includes/Wiki.php index e6ccbe5a40..d4840cc22e 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -178,7 +178,7 @@ class MediaWiki { wfProfileIn( __METHOD__ ); $request = $this->context->getRequest(); - $title = $this->context->getTitle(); + $requestTitle = $title = $this->context->getTitle(); $output = $this->context->getOutput(); $user = $this->context->getUser(); @@ -302,7 +302,7 @@ class MediaWiki { global $wgArticle; $wgArticle = new DeprecatedGlobal( 'wgArticle', $article, '1.18' ); - $this->performAction( $article ); + $this->performAction( $article, $requestTitle ); } elseif ( is_string( $article ) ) { $output->redirect( $article ); } else { @@ -396,8 +396,9 @@ class MediaWiki { * Perform one of the "standard" actions * * @param $page Page + * @param $requestTitle The original title, before any redirects were applied */ - private function performAction( Page $page ) { + private function performAction( Page $page, Title $requestTitle ) { global $wgUseSquid, $wgSquidMaxage; wfProfileIn( __METHOD__ ); @@ -420,7 +421,7 @@ class MediaWiki { if ( $action instanceof Action ) { # Let Squid cache things if we can purge them. if ( $wgUseSquid && - in_array( $request->getFullRequestURL(), $title->getSquidURLs() ) + in_array( $request->getFullRequestURL(), $requestTitle->getSquidURLs() ) ) { $output->setSquidMaxage( $wgSquidMaxage ); } @@ -573,9 +574,6 @@ class MediaWiki { // Execute a job from the queue $this->doJobs(); - // Log message usage, if $wgAdaptiveMessageCache is set to true - MessageCache::logMessages(); - // Log profiling data, e.g. in the database or UDP wfLogProfilingData(); @@ -596,28 +594,51 @@ class MediaWiki { if ( $wgJobRunRate <= 0 || wfReadOnly() ) { return; } + if ( $wgJobRunRate < 1 ) { $max = mt_getrandmax(); if ( mt_rand( 0, $max ) > $max * $wgJobRunRate ) { - return; + return; // the higher $wgJobRunRate, the less likely we return here } $n = 1; } else { $n = intval( $wgJobRunRate ); } - while ( $n-- && false != ( $job = Job::pop() ) ) { - $output = $job->toString() . "\n"; - $t = - microtime( true ); - $success = $job->run(); - $t += microtime( true ); - $t = round( $t * 1000 ); - if ( !$success ) { - $output .= "Error: " . $job->getLastError() . ", Time: $t ms\n"; - } else { - $output .= "Success, Time: $t ms\n"; + $group = JobQueueGroup::singleton(); + $types = $group->getDefaultQueueTypes(); + shuffle( $types ); // avoid starvation + + // Scan the queues for a job N times... + do { + $jobFound = false; // found a job in any queue? + // Find a queue with a job on it and run it... + foreach ( $types as $i => $type ) { + $queue = $group->get( $type ); + if ( $queue->isEmpty() ) { + unset( $types[$i] ); // don't keep checking this queue + continue; + } + $job = $queue->pop(); + if ( $job ) { + $jobFound = true; + $output = $job->toString() . "\n"; + $t = - microtime( true ); + $success = $job->run(); + $queue->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"; + } + wfDebugLog( 'jobqueue', $output ); + break; + } else { + unset( $types[$i] ); // don't keep checking this queue + } } - wfDebugLog( 'jobqueue', $output ); - } + } while ( --$n && $jobFound ); } }