From 086ae52d12011746a75f5588e877347bc0457352 Mon Sep 17 00:00:00 2001
From: Pierre Schmitz
Date: Fri, 21 Mar 2008 11:49:34 +0100
Subject: Update auf MediaWiki 1.12.0
---
includes/Exception.php | 42 ++++++++++++++++++++++++++++++++----------
1 file changed, 32 insertions(+), 10 deletions(-)
(limited to 'includes/Exception.php')
diff --git a/includes/Exception.php b/includes/Exception.php
index 02819cc9..2fd54352 100644
--- a/includes/Exception.php
+++ b/includes/Exception.php
@@ -16,6 +16,26 @@ class MWException extends Exception
return is_object( $wgLang );
}
+ function runHooks( $name, $args = array() ) {
+ global $wgExceptionHooks;
+ if( !isset( $wgExceptionHooks ) || !is_array( $wgExceptionHooks ) )
+ return; // Just silently ignore
+ if( !array_key_exists( $name, $wgExceptionHooks ) || !is_array( $wgExceptionHooks[ $name ] ) )
+ return;
+ $hooks = $wgExceptionHooks[ $name ];
+ $callargs = array_merge( array( $this ), $args );
+
+ foreach( $hooks as $hook ) {
+ if( is_string( $hook ) || ( is_array( $hook ) && count( $hook ) >= 2 && is_string( $hook[0] ) ) ) { //'function' or array( 'class', hook' )
+ $result = call_user_func_array( $hook, $callargs );
+ } else {
+ $result = null;
+ }
+ if( is_string( $result ) )
+ return $result;
+ }
+ }
+
/** Get a message from i18n */
function msg( $key, $fallback /*[, params...] */ ) {
$args = array_slice( func_get_args(), 2 );
@@ -35,7 +55,8 @@ class MWException extends Exception
"
\n";
} else {
return "Set \$wgShowExceptionDetails = true; " .
- "in LocalSettings.php to show detailed debugging information.
";
+ "at the bottom of LocalSettings.php to show detailed " .
+ "debugging information.";
}
}
@@ -82,27 +103,29 @@ class MWException extends Exception
$wgOut->enableClientCache( false );
$wgOut->redirect( '' );
$wgOut->clearHTML();
- $wgOut->addHTML( $this->getHTML() );
+ if( $hookResult = $this->runHooks( get_class( $this ) ) ) {
+ $wgOut->addHTML( $hookResult );
+ } else {
+ $wgOut->addHTML( $this->getHTML() );
+ }
$wgOut->output();
} else {
+ if( $hookResult = $this->runHooks( get_class( $this ) . "Raw" ) ) {
+ die( $hookResult );
+ }
echo $this->htmlHeader();
echo $this->getHTML();
echo $this->htmlFooter();
}
}
- /** Print the exception report using text */
- function reportText() {
- echo $this->getText();
- }
-
/* Output a report about the exception and takes care of formatting.
* It will be either HTML or plain text based on $wgCommandLineMode.
*/
function report() {
global $wgCommandLineMode;
if ( $wgCommandLineMode ) {
- $this->reportText();
+ fwrite( STDERR, $this->getText() );
} else {
$log = $this->getLogMessage();
if ( $log ) {
@@ -135,7 +158,6 @@ class MWException extends Exception
function htmlFooter() {
echo "