MWExceptionRenderer: Fix db error outage page
Set content encoding and add some content to the header tag. Bug: T195525 Change-Id: Ieabfe18280359459e9462204371d3fe8d62a4177
This commit is contained in:
parent
8536c0ca88
commit
94b58b2c26
1 changed files with 12 additions and 5 deletions
|
|
@ -47,13 +47,15 @@ class MWExceptionRenderer {
|
|||
self::printError( self::getText( $e ) );
|
||||
} elseif ( $mode === self::AS_PRETTY ) {
|
||||
self::statusHeader( 500 );
|
||||
self::header( "Content-Type: $wgMimeType; charset=utf-8" );
|
||||
if ( $e instanceof DBConnectionError ) {
|
||||
self::reportOutageHTML( $e );
|
||||
} else {
|
||||
self::header( "Content-Type: $wgMimeType; charset=utf-8" );
|
||||
self::reportHTML( $e );
|
||||
}
|
||||
} else {
|
||||
self::statusHeader( 500 );
|
||||
self::header( "Content-Type: $wgMimeType; charset=utf-8" );
|
||||
if ( $eNew ) {
|
||||
$message = "MediaWiki internal error.\n\n";
|
||||
if ( self::showBackTrace( $e ) ) {
|
||||
|
|
@ -292,7 +294,7 @@ class MWExceptionRenderer {
|
|||
* @param Exception|Throwable $e
|
||||
*/
|
||||
private static function reportOutageHTML( $e ) {
|
||||
global $wgShowDBErrorBacktrace, $wgShowHostnames, $wgShowSQLErrors;
|
||||
global $wgShowDBErrorBacktrace, $wgShowHostnames, $wgShowSQLErrors, $wgSitename;
|
||||
|
||||
$sorry = htmlspecialchars( self::msg(
|
||||
'dberr-problems',
|
||||
|
|
@ -317,8 +319,13 @@ class MWExceptionRenderer {
|
|||
}
|
||||
|
||||
MessageCache::singleton()->disable(); // no DB access
|
||||
|
||||
$html = "<h1>$sorry</h1><p>$again</p><p><small>$info</small></p>";
|
||||
$html = "<!DOCTYPE html>\n" .
|
||||
'<html><head>' .
|
||||
'<title>' .
|
||||
htmlspecialchars( $wgSitename ) .
|
||||
'</title>' .
|
||||
'<style>body { font-family: sans-serif; margin: 0; padding: 0.5em 2em; }</style>' .
|
||||
"</head><body><h1>$sorry</h1><p>$again</p><p><small>$info</small></p>";
|
||||
|
||||
if ( $wgShowDBErrorBacktrace ) {
|
||||
$html .= '<p>Backtrace:</p><pre>' .
|
||||
|
|
@ -327,7 +334,7 @@ class MWExceptionRenderer {
|
|||
|
||||
$html .= '<hr />';
|
||||
$html .= self::googleSearchForm();
|
||||
|
||||
$html .= '</body></html>';
|
||||
echo $html;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue