Avoid double-rendering on late exceptions
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 18 Mar 2016 19:11:45 +0000 (12:11 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Fri, 18 Mar 2016 19:11:45 +0000 (12:11 -0700)
Bug: T129657
Change-Id: I86af834b842bc056b57b2a55a9e1385481d5781d

includes/OutputPage.php

index 6774072..cffa744 100644 (file)
@@ -2315,11 +2315,21 @@ class OutputPage extends ContextSource {
                        // adding of CSS or Javascript by extensions.
                        Hooks::run( 'BeforePageDisplay', [ &$this, &$sk ] );
 
-                       $sk->outputPage();
+                       try {
+                               $sk->outputPage();
+                       } catch ( Exception $e ) {
+                               ob_end_clean(); // bug T129657
+                               throw $e;
+                       }
                }
 
-               // This hook allows last minute changes to final overall output by modifying output buffer
-               Hooks::run( 'AfterFinalPageOutput', [ $this ] );
+               try {
+                       // This hook allows last minute changes to final overall output by modifying output buffer
+                       Hooks::run( 'AfterFinalPageOutput', [ $this ] );
+               } catch ( Exception $e ) {
+                       ob_end_clean(); // bug T129657
+                       throw $e;
+               }
 
                $this->sendCacheControl();