39 private function useOutputPage() {
42 !empty( $GLOBALS[
'wgFullyInitialised'] ) &&
43 !empty( $GLOBALS[
'wgOut'] ) &&
44 !defined(
'MEDIAWIKI_INSTALL' ) &&
69 foreach ( $this->getTrace() as $frame ) {
70 if ( isset( $frame[
'class'] ) && $frame[
'class'] === LocalisationCache::class ) {
92 }
catch ( Exception $e ) {
95 if ( $res ===
false ) {
100 '{{SITENAME}}' =>
'MediaWiki',
115 if ( MWExceptionRenderer::shouldShowExceptionDetails() ) {
116 return '<p>' . nl2br( htmlspecialchars( MWExceptionHandler::getLogMessage( $this ) ) ) .
117 '</p><p>Backtrace:</p><p>' .
118 nl2br( htmlspecialchars( MWExceptionHandler::getRedactedTraceAsString( $this ) ) ) .
121 $logId = WebRequest::getRequestId();
122 $type = static::class;
123 return Html::errorBox(
125 '[' . $logId .
'] ' .
126 gmdate(
'Y-m-d H:i:s' ) .
": " .
127 $this->
msg(
"internalerror-fatal-exception",
128 "Fatal exception of type $1",
131 MWExceptionHandler::getURL()
134 "<!-- Set \$wgShowExceptionDetails = true; " .
135 "at the bottom of LocalSettings.php to show detailed " .
136 "debugging information. -->";
149 if ( MWExceptionRenderer::shouldShowExceptionDetails() ) {
150 return MWExceptionHandler::getLogMessage( $this ) .
151 "\nBacktrace:\n" . MWExceptionHandler::getRedactedTraceAsString( $this ) .
"\n";
153 return "Set \$wgShowExceptionDetails = true; " .
154 "in LocalSettings.php to show detailed debugging information.\n";
167 return $this->
msg(
'internalerror',
'Internal error' );
179 if ( $this->useOutputPage() ) {
180 $wgOut->prepareErrorPage();
193 self::header(
'Content-Type: text/html; charset=UTF-8' );
194 echo
"<!DOCTYPE html>\n" .
198 htmlspecialchars( $this->
msg(
'pagetitle',
'$1 - MediaWiki', $this->
getPageTitle() ) ) .
200 '<style>body { font-family: sans-serif; margin: 0; padding: 0.5em 2em; }</style>' .
205 echo
"</body></html>\n";
216 if ( defined(
'MW_API' ) ) {
217 self::header(
'MediaWiki-API-Error: internal_api_error_' . static::class );
220 if ( self::isCommandLine() ) {
222 $this->writeToCommandLine( $message );
224 self::statusHeader( 500 );
234 if (
MWDebug::detectDeprecatedOverride( $this, __CLASS__,
'report' ) ) {
240 $detectedOverrides = [
241 'getHTML' => MWDebug::detectDeprecatedOverride( $this, __CLASS__,
'getHTML',
'1.42' ),
242 'getText' => MWDebug::detectDeprecatedOverride( $this, __CLASS__,
'getText',
'1.42' ),
243 'getPageTitle' => MWDebug::detectDeprecatedOverride( $this, __CLASS__,
'getPageTitle',
'1.42' ),
244 'reportHTML' => MWDebug::detectDeprecatedOverride( $this, __CLASS__,
'reportHTML',
'1.42' ),
247 return (
bool)array_filter( $detectedOverrides );
256 private function writeToCommandLine( $message ) {
258 if ( !defined(
'MW_PHPUNIT_TEST' ) && defined(
'STDERR' ) ) {
259 fwrite( STDERR, $message );
280 private static function header(
$header ) {
281 if ( !headers_sent() ) {
286 private static function statusHeader( $code ) {
287 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.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
if(!defined( 'MW_NO_SESSION') &&MW_ENTRY_POINT !=='cli') $wgOut
array $params
The job parameters.
if(!defined('MW_SETUP_CALLBACK'))
static header( $code)
Output an HTTP status code header.
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.