X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FMediaWiki.php;h=fbacb2504e61a8b661ab99c2dc46d7ab7778f895;hb=09f4a785b33c346f668067b526594ccbc73b8bf0;hp=e9946a8f18eb800b9224aad8107292dc729cbe24;hpb=a7c124f2e96a13464e51cb2ec9885f2d42357f57;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php index e9946a8f18..fbacb2504e 100644 --- a/includes/MediaWiki.php +++ b/includes/MediaWiki.php @@ -283,9 +283,11 @@ class MediaWiki { * /w/index.php?title=Foo_Bar -> /wiki/Foo_Bar * - Don't redirect anything with query parameters other than 'title' or 'action=view'. * + * @param Title $title * @return bool True if a redirect was set. + * @throws HttpError */ - private function tryNormaliseRedirect( $title ) { + private function tryNormaliseRedirect( Title $title ) { $request = $this->context->getRequest(); $output = $this->context->getOutput(); @@ -508,29 +510,26 @@ class MediaWiki { * This function does work that can be done *after* the * user gets the HTTP response so they don't block on it * + * This manages deferred updates, job insertion, + * final commit, and the logging of profiling data + * * @param string $mode Use 'fast' to always skip job running * @since 1.26 */ public function doPostOutputShutdown( $mode = 'normal' ) { - // Show profiling data if enabled + // Show visible profiling data if enabled (which cannot be post-send) Profiler::instance()->logDataPageOutputOnly(); $that = $this; $callback = function () use ( $that, $mode ) { try { - // Assure deferred updates are not in the main transaction - wfGetLBFactory()->commitMasterChanges(); - // Run jobs occasionally, if enabled - if ( $mode === 'normal' ) { - $that->triggerJobs(); - } - // Do deferred updates and job insertion and final commit - $that->restInPeace(); + $that->restInPeace( $mode ); } catch ( Exception $e ) { MWExceptionHandler::handleException( $e ); } }; + // Defer everything else... if ( function_exists( 'register_postsend_function' ) ) { // https://github.com/facebook/hhvm/issues/1230 register_postsend_function( $callback ); @@ -693,8 +692,12 @@ class MediaWiki { /** * Ends this task peacefully + * @param string $mode Use 'fast' to always skip job running */ - public function restInPeace() { + public function restInPeace( $mode = 'fast' ) { + // Assure deferred updates are not in the main transaction + wfGetLBFactory()->commitMasterChanges(); + // Ignore things like master queries/connections on GET requests // as long as they are in deferred updates (which catch errors). Profiler::instance()->getTransactionProfiler()->resetExpectations(); @@ -705,6 +708,12 @@ class MediaWiki { // Make sure any lazy jobs are pushed JobQueueGroup::pushLazyJobs(); + // Now that everything specific to this request is done, + // try to occasionally run jobs (if enabled) from the queues + if ( $mode === 'normal' ) { + $this->triggerJobs(); + } + // Log profiling data, e.g. in the database or UDP wfLogProfilingData();