From 4d673afd750991d0cc9d96023588ac7e238da93f Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Fri, 18 Mar 2016 12:11:45 -0700 Subject: [PATCH] Avoid double-rendering on late exceptions Bug: T129657 Change-Id: I86af834b842bc056b57b2a55a9e1385481d5781d --- includes/OutputPage.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 6774072d11..cffa744bae 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -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(); -- 2.20.1