From 8fc7ebaaa2ad465c6163a18991a37504b25eb9cb Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 24 May 2017 12:01:31 -0700 Subject: [PATCH] Push lazy jobs when exceptions are handled by MWExceptionHandler Remove the exit(1), which does not seem to be needed by any callers. Doing so means that post-send updates can still happen, such as the pushing of lazy jobs. Better avoid showing exceptions in doPostOutputShutdown(), given that an error may have already been shown. By the post-send part, it's to late to show errors anyway. Bug: T100085 Change-Id: Ib1c75323f222a0e02603d6415626a4b233e8e1c7 --- includes/MediaWiki.php | 22 ++++++++++++++-------- includes/exception/MWExceptionHandler.php | 2 -- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php index 19e827dd03..9fdc95ae0f 100644 --- a/includes/MediaWiki.php +++ b/includes/MediaWiki.php @@ -545,7 +545,6 @@ class MediaWiki { print MWExceptionRenderer::getHTML( $e ); exit; } - } MWExceptionHandler::handleException( $e ); @@ -720,21 +719,28 @@ class MediaWiki { * @since 1.26 */ public function doPostOutputShutdown( $mode = 'normal' ) { - $timing = $this->context->getTiming(); - $timing->mark( 'requestShutdown' ); - - // Show visible profiling data if enabled (which cannot be post-send) - Profiler::instance()->logDataPageOutputOnly(); + // Perform the last synchronous operations... + try { + // Record backend request timing + $timing = $this->context->getTiming(); + $timing->mark( 'requestShutdown' ); + // Show visible profiling data if enabled (which cannot be post-send) + Profiler::instance()->logDataPageOutputOnly(); + } catch ( Exception $e ) { + // An error may already have been shown in run(), so just log it to be safe + MWExceptionHandler::rollbackMasterChangesAndLog( $e ); + } + // Defer everything else if possible... $callback = function () use ( $mode ) { try { $this->restInPeace( $mode ); } catch ( Exception $e ) { - MWExceptionHandler::handleException( $e ); + // If this is post-send, then displaying errors can cause broken HTML + MWExceptionHandler::rollbackMasterChangesAndLog( $e ); } }; - // Defer everything else... if ( function_exists( 'register_postsend_function' ) ) { // https://github.com/facebook/hhvm/issues/1230 register_postsend_function( $callback ); diff --git a/includes/exception/MWExceptionHandler.php b/includes/exception/MWExceptionHandler.php index ef8136687d..a2867a1879 100644 --- a/includes/exception/MWExceptionHandler.php +++ b/includes/exception/MWExceptionHandler.php @@ -128,8 +128,6 @@ class MWExceptionHandler { public static function handleException( $e ) { self::rollbackMasterChangesAndLog( $e ); self::report( $e ); - // Exit value should be nonzero for the benefit of shell jobs - exit( 1 ); } /** -- 2.20.1