38 public static function output(
$e, $mode, $eNew =
null ) {
41 if ( defined(
'MW_API' ) ) {
43 self::header(
'MediaWiki-API-Error: internal_api_error_' . get_class(
$e ) );
44 wfHttpError( 500,
'Internal Server Error', self::getText(
$e ) );
45 } elseif ( self::isCommandLine() ) {
47 } elseif ( $mode === self::AS_PRETTY ) {
49 self::header(
"Content-Type: $wgMimeType; charset=utf-8" );
57 self::header(
"Content-Type: $wgMimeType; charset=utf-8" );
59 $message =
"MediaWiki internal error.\n\n";
61 $message .=
'Original exception: ' .
62 MWExceptionHandler::getLogMessage(
$e ) .
63 "\nBacktrace:\n" . MWExceptionHandler::getRedactedTraceAsString(
$e ) .
64 "\n\nException caught inside exception handler: " .
65 MWExceptionHandler::getLogMessage( $eNew ) .
66 "\nBacktrace:\n" . MWExceptionHandler::getRedactedTraceAsString( $eNew );
68 $message .=
'Original exception: ' .
69 MWExceptionHandler::getPublicLogMessage(
$e );
70 $message .=
"\n\nException caught inside exception handler.\n\n" .
76 $message = MWExceptionHandler::getLogMessage(
$e ) .
78 MWExceptionHandler::getRedactedTraceAsString(
$e ) .
"\n";
80 $message = MWExceptionHandler::getPublicLogMessage(
$e );
83 echo nl2br( htmlspecialchars( $message ) ) .
"\n";
93 foreach (
$e->getTrace() as $frame ) {
94 if ( isset( $frame[
'class'] ) && $frame[
'class'] === LocalisationCache::class ) {
104 !empty(
$GLOBALS[
'wgFullyInitialised'] ) &&
106 RequestContext::getMain()->getTitle() &&
107 !defined(
'MEDIAWIKI_INSTALL' )
119 if ( self::useOutputPage(
$e ) ) {
121 $wgOut->prepareErrorPage(
$e->getPageTitle() );
123 $wgOut->prepareErrorPage( self::msg(
'readonly',
'Database is locked' ) );
125 $wgOut->prepareErrorPage( self::msg(
'databaseerror',
'Database error' ) );
127 $wgOut->prepareErrorPage( self::msg(
'internalerror',
'Internal error' ) );
132 $wgOut->addHTML( Html::element(
'p', [], Message::newFromSpecifier(
$e )->
text() ) );
134 $wgOut->addHTML( self::getHTML(
$e ) );
138 self::header(
'Content-Type: text/html; charset=utf-8' );
139 $pageTitle =
self::msg(
'internalerror',
'Internal error' );
140 echo
"<!DOCTYPE html>\n" .
144 htmlspecialchars( self::msg(
'pagetitle',
"$1 - $wgSitename", $pageTitle ) ) .
146 '<style>body { font-family: sans-serif; margin: 0; padding: 0.5em 2em; }</style>' .
151 echo
"</body></html>\n";
167 $html =
"<div class=\"errorbox mw-content-ltr\"><p>" .
168 nl2br( htmlspecialchars( MWExceptionHandler::getLogMessage(
$e ) ) ) .
169 '</p><p>Backtrace:</p><p>' .
170 nl2br( htmlspecialchars( MWExceptionHandler::getRedactedTraceAsString(
$e ) ) ) .
173 $logId = WebRequest::getRequestId();
174 $html =
"<div class=\"errorbox mw-content-ltr\">" .
176 '[' . $logId .
'] ' .
177 gmdate(
'Y-m-d H:i:s' ) .
": " .
178 self::msg(
"internalerror-fatal-exception",
179 "Fatal exception of type $1",
182 MWExceptionHandler::getURL()
184 "<!-- " . wordwrap( self::getShowBacktraceError(
$e ), 50 ) .
" -->";
201 $args = array_slice( func_get_args(), 2 );
206 }
catch ( Exception
$e ) {
225 return MWExceptionHandler::getLogMessage(
$e ) .
227 MWExceptionHandler::getRedactedTraceAsString(
$e ) .
"\n";
238 $var =
'$wgShowExceptionDetails = true;';
239 return "Set $var at the bottom of LocalSettings.php to show detailed debugging information.";
246 return !empty(
$GLOBALS[
'wgCommandLineMode'] );
253 if ( !headers_sent() ) {
262 if ( !headers_sent() ) {
277 if ( defined(
'STDERR' ) ) {
278 fwrite( STDERR, $message );
290 $sorry = htmlspecialchars( self::msg(
292 'Sorry! This site is experiencing technical difficulties.'
294 $again = htmlspecialchars( self::msg(
296 'Try waiting a few minutes and reloading.'
302 Html::element(
'span', [
'dir' =>
'ltr' ],
$e->getMessage() ),
303 htmlspecialchars( self::msg(
'dberr-info',
'($1)' ) )
306 $info = htmlspecialchars( self::msg(
308 '(Cannot access the database)'
312 MessageCache::singleton()->disable();
313 $html =
"<!DOCTYPE html>\n" .
318 '<style>body { font-family: sans-serif; margin: 0; padding: 0.5em 2em; }</style>' .
319 "</head><body><h1>$sorry</h1><p>$again</p><p><small>$info</small></p>";
322 $html .=
'<p>Backtrace:</p><pre>' .
323 htmlspecialchars(
$e->getTraceAsString() ) .
'</pre>';
326 $html .=
'</body></html>';
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
$wgMimeType
The default Content-Type header.
$wgShowHostnames
Expose backend server host names through the API and various HTML comments.
$wgSitename
Name of the site.
$wgShowExceptionDetails
If set to true, uncaught exceptions will print the exception message and a complete stack trace to ou...
wfHttpError( $code, $label, $desc)
Provide a simple HTTP error.
wfMsgReplaceArgs( $message, $args)
Replace message parameter keys on the given formatted output.
static header( $code)
Output an HTTP status code header.
Class to expose exceptions to the client (API bots, users, admins using CLI scripts)
static printError( $message)
Print a message, if possible to STDERR.
static useOutputPage( $e)
static output( $e, $mode, $eNew=null)
static msg( $key, $fallback)
Get a message from i18n.
static reportHTML( $e)
Output the exception report using HTML.
static statusHeader( $code)
static reportOutageHTML( $e)
static getHTML( $e)
If $wgShowExceptionDetails is true, return a HTML message with a backtrace to the error,...
static getShowBacktraceError( $e)
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<div ...>$1</div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
returning false will NOT prevent logging $e