/**
* @param Exception|Throwable $e Original exception
- * @param integer $mode MWExceptionExposer::AS_* constant
+ * @param int $mode MWExceptionExposer::AS_* constant
* @param Exception|Throwable|null $eNew New exception from attempting to show the first
*/
public static function output( $e, $mode, $eNew = null ) {
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 ) ) {
private static function useOutputPage( $e ) {
// Can the extension use the Message class/wfMessage to get i18n-ed messages?
foreach ( $e->getTrace() as $frame ) {
- if ( isset( $frame['class'] ) && $frame['class'] === 'LocalisationCache' ) {
+ if ( isset( $frame['class'] ) && $frame['class'] === LocalisationCache::class ) {
return false;
}
}
// Show any custom GUI message before the details
if ( $e instanceof MessageSpecifier ) {
- $wgOut->addHTML( Message::newFromSpecifier( $e )->escaped() );
+ $wgOut->addHTML( Html::element( 'p', [], Message::newFromSpecifier( $e )->text() ) );
}
$wgOut->addHTML( self::getHTML( $e ) );
} else {
$logId = WebRequest::getRequestId();
$html = "<div class=\"errorbox mw-content-ltr\">" .
- '[' . $logId . '] ' .
- gmdate( 'Y-m-d H:i:s' ) . ": " .
- self::msg( "internalerror-fatal-exception",
- "Fatal exception of type $1",
- get_class( $e ),
- $logId,
- MWExceptionHandler::getURL()
- ) . "</div>\n" .
+ htmlspecialchars(
+ '[' . $logId . '] ' .
+ gmdate( 'Y-m-d H:i:s' ) . ": " .
+ self::msg( "internalerror-fatal-exception",
+ "Fatal exception of type $1",
+ get_class( $e ),
+ $logId,
+ MWExceptionHandler::getURL()
+ ) ) . "</div>\n" .
"<!-- " . wordwrap( self::getShowBacktraceError( $e ), 50 ) . " -->";
}
}
/**
- * @param integer $code
+ * @param int $code
*/
private static function statusHeader( $code ) {
if ( !headers_sent() ) {
* @param Exception|Throwable $e
*/
private static function reportOutageHTML( $e ) {
- global $wgShowDBErrorBacktrace, $wgShowHostnames, $wgShowSQLErrors;
+ global $wgShowDBErrorBacktrace, $wgShowHostnames, $wgShowSQLErrors, $wgSitename;
$sorry = htmlspecialchars( self::msg(
'dberr-problems',
}
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>' .
$html .= '<hr />';
$html .= self::googleSearchForm();
-
+ $html .= '</body></html>';
echo $html;
}