36 private function useOutputPage() {
39 !empty( $GLOBALS[
'wgFullyInitialised'] ) &&
40 !empty( $GLOBALS[
'wgOut'] ) &&
41 !defined(
'MEDIAWIKI_INSTALL' ) &&
66 foreach ( $this->getTrace() as $frame ) {
67 if ( isset( $frame[
'class'] ) && $frame[
'class'] === LocalisationCache::class ) {
89 }
catch ( Exception $e ) {
92 if (
$res ===
false ) {
97 '{{SITENAME}}' =>
'MediaWiki',
114 '</p><p>Backtrace:</p><p>' .
119 $type = static::class;
122 '[' . $logId .
'] ' .
123 gmdate(
'Y-m-d H:i:s' ) .
": " .
124 $this->
msg(
"internalerror-fatal-exception",
125 "Fatal exception of type $1",
131 "<!-- Set \$wgShowExceptionDetails = true; " .
132 "at the bottom of LocalSettings.php to show detailed " .
133 "debugging information. -->";
149 return "Set \$wgShowExceptionDetails = true; " .
150 "in LocalSettings.php to show detailed debugging information.\n";
162 return $this->
msg(
'internalerror',
'Internal error' );
171 if ( $this->useOutputPage() ) {
176 $wgOut->setHTMLTitle(
180 $wgOut->addHTML( $this->
getHTML() );
184 self::header(
'Content-Type: text/html; charset=UTF-8' );
185 echo
"<!DOCTYPE html>\n" .
189 htmlspecialchars( $this->
msg(
'pagetitle',
'$1 - MediaWiki', $this->
getPageTitle() ) ) .
191 '<style>body { font-family: sans-serif; margin: 0; padding: 0.5em 2em; }</style>' .
196 echo
"</body></html>\n";
207 if ( defined(
'MW_API' ) ) {
208 self::header(
'MediaWiki-API-Error: internal_api_error_' . static::class );
211 if ( self::isCommandLine() ) {
213 $this->writeToCommandLine( $message );
215 self::statusHeader( 500 );
226 private function writeToCommandLine( $message ) {
228 if ( !defined(
'MW_PHPUNIT_TEST' ) && defined(
'STDERR' ) ) {
229 fwrite( STDERR, $message );
242 return !empty( $GLOBALS[
'wgCommandLineMode'] );
250 private static function header(
$header ) {
251 if ( !headers_sent() ) {
256 private static function statusHeader( $code ) {
257 if ( !headers_sent() ) {
wfMsgReplaceArgs( $message, $args)
Replace message parameter keys on the given formatted output.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
if(!defined( 'MW_NO_SESSION') &&! $wgCommandLineMode) $wgOut
static errorBox( $html, $heading='', $className='')
Return an error box.
static header( $code)
Output an HTTP status code header.
static getRedactedTraceAsString(Throwable $e)
Generate a string representation of a throwable's stack trace.
static getLogMessage(Throwable $e)
Get a message formatting the throwable message and its origin.
static getURL()
If the exception occurred in the course of responding to a request, returns the requested URL.
static shouldShowExceptionDetails()
isLoggable()
Whether to log this exception in the exception debug log.
useMessageCache()
Can the extension use the Message class/wfMessage to get i18n-ed messages?
msg( $key, $fallback,... $params)
Get a message from i18n.
getHTML()
Format an HTML message for the current exception object.
static isCommandLine()
Check whether we are in command line mode or not to report the exception in the correct format.
report()
Output a report about the exception and takes care of formatting.
getPageTitle()
Return the title of the page when reporting this error in a HTTP response.
reportHTML()
Output the exception report using HTML.
getText()
Format plain text message for the current exception object.
static getRequestId()
Get the current request ID.