From 5fe9c4363eed213142616baa906ec9323b231191 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 17 Nov 2008 18:51:21 +0000 Subject: [PATCH] * Safer handling of non-MediaWiki exceptions -- now obeys our settings for formatting and path exposure. Applying Tim's fixes... --- RELEASE-NOTES | 3 +++ includes/Exception.php | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index e451dd7d5a..feb6aa1401 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -344,6 +344,9 @@ The following extensions are migrated into MediaWiki 1.14: * (bug 5530) Consistency between character encoding in {{PAGENAMEE}}, {{SUBPAGENAMEE}} and {{FULLPAGENAMEE}} * API siteinfo query no longer throws an exception for empty sifilter parameter. +* Safer handling of non-MediaWiki exceptions -- now obeys our settings for + formatting and path exposure. + === API changes in 1.14 === diff --git a/includes/Exception.php b/includes/Exception.php index 05ddfd107a..eb7159861c 100644 --- a/includes/Exception.php +++ b/includes/Exception.php @@ -283,7 +283,16 @@ function wfReportException( Exception $e ) { } } } else { - echo $e->__toString(); + $message = "Unexpected non-MediaWiki exception encountered, of type \"" . get_class( $e ) . "\"\n" . + $e->__toString() . "\n"; + if ( $GLOBALS['wgShowExceptionDetails'] ) { + $message .= "\n" . $e->getTraceAsString() ."\n"; + } + if ( !empty( $GLOBALS['wgCommandLineMode'] ) ) { + wfPrintError( $message ); + } else { + echo nl2br( htmlspecialchars( $message ) ). "\n"; + } } } -- 2.20.1