Chad has uploaded a new change for review. https://gerrit.wikimedia.org/r/133183
Change subject: MWException: Don't send headers multiple times ...................................................................... MWException: Don't send headers multiple times Ideally we wouldn't have sent headers yet, but in some weird code paths where we output stuff raw (like Export) we might have already sent them. All depends on when the failure happened. Should silence all of the "headers already sent" being seen from exports. Change-Id: I12e0532e93d30b2255f73a9d0e017c73e30c3e28 (cherry picked from commit cfbeb437a3bf688f07681d8b900f3d0a13f25497) --- M includes/exception/MWException.php 1 file changed, 15 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/83/133183/1 diff --git a/includes/exception/MWException.php b/includes/exception/MWException.php index 82303b9..782a44b 100644 --- a/includes/exception/MWException.php +++ b/includes/exception/MWException.php @@ -219,7 +219,7 @@ $wgOut->output(); } else { - header( 'Content-Type: text/html; charset=utf-8' ); + self::header( 'Content-Type: text/html; charset=utf-8' ); echo "<!DOCTYPE html>\n" . '<html><head>' . // Mimick OutputPage::setPageTitle behaviour @@ -251,14 +251,14 @@ if ( defined( 'MW_API' ) ) { // Unhandled API exception, we can't be sure that format printer is alive - header( 'MediaWiki-API-Error: internal_api_error_' . get_class( $this ) ); + self::header( 'MediaWiki-API-Error: internal_api_error_' . get_class( $this ) ); wfHttpError( 500, 'Internal Server Error', $this->getText() ); } elseif ( self::isCommandLine() ) { MWExceptionHandler::printError( $this->getText() ); } else { - header( 'HTTP/1.1 500 MediaWiki exception' ); - header( 'Status: 500 MediaWiki exception', true ); - header( "Content-Type: $wgMimeType; charset=utf-8", true ); + self::header( 'HTTP/1.1 500 MediaWiki exception' ); + self::header( 'Status: 500 MediaWiki exception' ); + self::header( "Content-Type: $wgMimeType; charset=utf-8" ); $this->reportHTML(); } @@ -273,4 +273,14 @@ public static function isCommandLine() { return !empty( $GLOBALS['wgCommandLineMode'] ); } + + /** + * Send a header, if we haven't already sent them. We shouldn't, + * but sometimes we might in a weird case like Export + */ + private static function header( $header ) { + if ( !headers_sent() ) { + header( $header ); + } + } } -- To view, visit https://gerrit.wikimedia.org/r/133183 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I12e0532e93d30b2255f73a9d0e017c73e30c3e28 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: wmf/1.24wmf3 Gerrit-Owner: Chad <ch...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits