X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FException.php;h=9f6d5bdc6b7e0c309bd5b25f21404e8c96c9169d;hb=bae670cf03d81b8128ba7aadcfaa61d3b381cf2c;hp=c75da5a74ee56015bb6ce39843fd99d8d42ea718;hpb=8de59d1452824186e0555e644cd95fc4694c2bf9;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/Exception.php b/includes/Exception.php
index c75da5a74e..9f6d5bdc6b 100644
--- a/includes/Exception.php
+++ b/includes/Exception.php
@@ -1,6 +1,21 @@
Backtrace:
' . nl2br( htmlspecialchars( $this->getTraceAsString() ) ) .
"
\n";
} else {
- return "Set \$wgShowExceptionDetails = true; " .
+ return
+ "
" .
+ '[' . $this->getLogId() . '] ' .
+ gmdate( 'Y-m-d H:i:s' ) .
+ ": Fatal exception of type " . get_class( $this ) . "
\n" .
+ "";
}
}
@@ -141,6 +164,13 @@ class MWException extends Exception {
return $this->msg( 'internalerror', "Internal error" );
}
+ function getLogId() {
+ if ( $this->logId === null ) {
+ $this->logId = wfRandomString( 8 );
+ }
+ return $this->logId;
+ }
+
/**
* Return the requested URL and point to file and line number from which the
* exception occured
@@ -150,6 +180,7 @@ class MWException extends Exception {
function getLogMessage() {
global $wgRequest;
+ $id = $this->getLogId();
$file = $this->getFile();
$line = $this->getLine();
$message = $this->getMessage();
@@ -163,7 +194,7 @@ class MWException extends Exception {
$url = '[no req]';
}
- return "$url Exception from line $line of $file: $message";
+ return "[$id] $url Exception from line $line of $file: $message";
}
/** Output the exception report using HTML */
@@ -197,10 +228,15 @@ class MWException extends Exception {
* It will be either HTML or plain text based on isCommandLine().
*/
function report() {
+ global $wgLogExceptionBacktrace;
$log = $this->getLogMessage();
if ( $log ) {
- wfDebugLog( 'exception', $log );
+ if ( $wgLogExceptionBacktrace ) {
+ wfDebugLog( 'exception', $log . "\n" . $this->getTraceAsString() . "\n" );
+ } else {
+ wfDebugLog( 'exception', $log );
+ }
}
if ( defined( 'MW_API' ) ) {
@@ -210,6 +246,9 @@ class MWException extends Exception {
} elseif ( self::isCommandLine() ) {
MWExceptionHandler::printError( $this->getText() );
} else {
+ header( "HTTP/1.1 500 MediaWiki exception" );
+ header( "Status: 500 MediaWiki exception", true );
+
$this->reportHTML();
}
}
@@ -441,7 +480,7 @@ class HttpError extends MWException {
$this->content = $content;
}
- public function reportHTML() {
+ public function report() {
$httpMessage = HttpStatus::getMessage( $this->httpCode );
header( "Status: {$this->httpCode} {$httpMessage}" );
@@ -461,7 +500,7 @@ class HttpError extends MWException {
$content = htmlspecialchars( $this->content );
}
- print "\n".
+ print "\n".
"$header\n" .
"$header
$content
\n";
}