From d81f562b712f2387fa02290bf2ca86392ab356f2 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 11 Oct 2006 20:21:25 +0000 Subject: Aktualisierung auf Version 1.8.1 --- includes/Exception.php | 54 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 15 deletions(-) (limited to 'includes/Exception.php') diff --git a/includes/Exception.php b/includes/Exception.php index 1e24515b..56f18d5a 100644 --- a/includes/Exception.php +++ b/includes/Exception.php @@ -3,7 +3,8 @@ class MWException extends Exception { function useOutputPage() { - return !empty( $GLOBALS['wgFullyInitialised'] ); + return !empty( $GLOBALS['wgFullyInitialised'] ) && + !empty( $GLOBALS['wgArticle'] ) && !empty( $GLOBALS['wgTitle'] ); } function useMessageCache() { @@ -19,16 +20,28 @@ class MWException extends Exception return wfMsgReplaceArgs( $fallback, $args ); } } - + function getHTML() { - return '

' . htmlspecialchars( $this->getMessage() ) . - '

Backtrace:

' . nl2br( htmlspecialchars( $this->getTraceAsString() ) ) . - "

\n"; + global $wgShowExceptionDetails; + if( $wgShowExceptionDetails ) { + return '

' . htmlspecialchars( $this->getMessage() ) . + '

Backtrace:

' . nl2br( htmlspecialchars( $this->getTraceAsString() ) ) . + "

\n"; + } else { + return "

Set \$wgShowExceptionDetails = true; " . + "in LocalSettings.php to show detailed debugging information.

"; + } } function getText() { - return $this->getMessage() . - "\nBacktrace:\n" . $this->getTraceAsString() . "\n"; + global $wgShowExceptionDetails; + if( $wgShowExceptionDetails ) { + return $this->getMessage() . + "\nBacktrace:\n" . $this->getTraceAsString() . "\n"; + } else { + return "

Set \$wgShowExceptionDetails = true; " . + "in LocalSettings.php to show detailed debugging information.

"; + } } function getPageTitle() { @@ -40,6 +53,13 @@ class MWException extends Exception } } + function getLogMessage() { + $file = $this->getFile(); + $line = $this->getLine(); + $message = $this->getMessage(); + return "{$_SERVER['REQUEST_URI']} Exception from line $line of $file: $message"; + } + function reportHTML() { global $wgOut; if ( $this->useOutputPage() ) { @@ -67,6 +87,10 @@ class MWException extends Exception if ( $wgCommandLineMode ) { $this->reportText(); } else { + $log = $this->getLogMessage(); + if ( $log ) { + wfDebugLog( 'exception', $log ); + } $this->reportHTML(); } } @@ -93,11 +117,12 @@ class MWException extends Exception function htmlFooter() { echo ""; - } + } + } /** - * Exception class which takes an HTML error message, and does not + * Exception class which takes an HTML error message, and does not * produce a backtrace. Replacement for OutputPage::fatalError(). */ class FatalError extends MWException { @@ -145,11 +170,11 @@ function wfReportException( Exception $e ) { $e->report(); } catch ( Exception $e2 ) { // Exception occurred from within exception handler - // Show a simpler error message for the original exception, + // Show a simpler error message for the original exception, // don't try to invoke report() $message = "MediaWiki internal error.\n\n" . - "Original exception: " . $e->__toString() . - "\n\nException caught inside exception handler: " . + "Original exception: " . $e->__toString() . + "\n\nException caught inside exception handler: " . $e2->__toString() . "\n"; if ( !empty( $GLOBALS['wgCommandLineMode'] ) ) { @@ -165,7 +190,7 @@ function wfReportException( Exception $e ) { /** * Exception handler which simulates the appropriate catch() handling: - * + * * try { * ... * } catch ( MWException $e ) { @@ -181,8 +206,7 @@ function wfExceptionHandler( $e ) { // Final cleanup, similar to wfErrorExit() if ( $wgFullyInitialised ) { try { - wfProfileClose(); - logProfilingData(); // uses $wgRequest, hence the $wgFullyInitialised condition + wfLogProfilingData(); // uses $wgRequest, hence the $wgFullyInitialised condition } catch ( Exception $e ) {} } -- cgit v1.2.3-54-g00ecf