Push lazy jobs when exceptions are handled by MWExceptionHandler
authorAaron Schulz <aschulz@wikimedia.org>
Wed, 24 May 2017 19:01:31 +0000 (12:01 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Sat, 1 Jul 2017 00:03:11 +0000 (00:03 +0000)
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
includes/exception/MWExceptionHandler.php

index 19e827d..9fdc95a 100644 (file)
@@ -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 );
index ef81366..a2867a1 100644 (file)
@@ -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 );
        }
 
        /**