Oops, forgot to change this in r71426
[lhc/web/wiklou.git] / includes / Exception.php
index b2d668c..0b77322 100644 (file)
@@ -1,10 +1,17 @@
 <?php
+/**
+ * Exception class and handler
+ *
+ * @file
+ */
+
 /**
  * @defgroup Exception Exception
  */
 
 /**
  * MediaWiki exception
+ *
  * @ingroup Exception
  */
 class MWException extends Exception {
@@ -26,7 +33,7 @@ class MWException extends Exception {
        function useMessageCache() {
                global $wgLang;
                foreach ( $this->getTrace() as $frame ) {
-                       if ( $frame['class'] == 'LocalisationCache' ) {
+                       if ( isset( $frame['class'] ) && $frame['class'] === 'LocalisationCache' ) {
                                return false;
                        }
                }
@@ -36,9 +43,9 @@ class MWException extends Exception {
        /**
         * Run hook to allow extensions to modify the text of the exception
         *
-        * @param String $name class name of the exception
-        * @param Array $args arguments to pass to the callback functions
-        * @return mixed string to output or null if any hook has been called
+        * @param $name String: class name of the exception
+        * @param $args Array: arguments to pass to the callback functions
+        * @return Mixed: string to output or null if any hook has been called
         */
        function runHooks( $name, $args = array() ) {
                global $wgExceptionHooks;
@@ -63,9 +70,9 @@ class MWException extends Exception {
        /**
         * Get a message from i18n
         *
-        * @param String $key message name
-        * @param String $fallback default message if the message cache can't be
-        *                         called by the exception
+        * @param $key String: message name
+        * @param $fallback String: default message if the message cache can't be
+        *                  called by the exception
         * The function also has other parameters that are arguments for the message
         * @return String message with arguments replaced
         */
@@ -127,7 +134,7 @@ class MWException extends Exception {
         * Return the requested URL and point to file and line number from which the
         * exception occured
         *
-        * @return string
+        * @return String
         */
        function getLogMessage() {
                global $wgRequest;
@@ -197,7 +204,7 @@ class MWException extends Exception {
         * $wgOut to output the exception.
         */
        function htmlHeader() {
-               global $wgLogo, $wgSitename, $wgOutputEncoding;
+               global $wgLogo, $wgOutputEncoding;
 
                if ( !headers_sent() ) {
                        header( 'HTTP/1.0 500 Internal Server Error' );
@@ -283,6 +290,8 @@ function wfInstallExceptionHandler() {
  * Report an exception to the user
  */
 function wfReportException( Exception $e ) {
+       global $wgShowExceptionDetails;
+
        $cmdLine = MWException::isCommandLine();
        if ( $e instanceof MWException ) {
                try {
@@ -292,11 +301,14 @@ function wfReportException( Exception $e ) {
                        // Show a simpler error message for the original exception,
                        // don't try to invoke report()
                        $message = "MediaWiki internal error.\n\n";
-                       if ( $GLOBALS['wgShowExceptionDetails'] )
-                               $message .= "Original exception: " . $e->__toString();
-                       $message .= "\n\nException caught inside exception handler";
-                       if ( $GLOBALS['wgShowExceptionDetails'] )
-                               $message .= ": " . $e2->__toString();
+                       if ( $wgShowExceptionDetails ) {
+                               $message .= 'Original exception: ' . $e->__toString() . "\n\n" .
+                                       'Exception caught inside exception handler: ' . $e2->__toString();
+                       } else {
+                               $message .= "Exception caught inside exception handler.\n\n" .
+                                       "Set \$wgShowExceptionDetails = true; at the bottom of LocalSettings.php " .
+                                       "to show detailed debugging information.";
+                       }
                        $message .= "\n";
                        if ( $cmdLine ) {
                                wfPrintError( $message );
@@ -307,7 +319,7 @@ function wfReportException( Exception $e ) {
        } else {
                $message = "Unexpected non-MediaWiki exception encountered, of type \"" . get_class( $e ) . "\"\n" .
                        $e->__toString() . "\n";
-               if ( $GLOBALS['wgShowExceptionDetails'] ) {
+               if ( $wgShowExceptionDetails ) {
                        $message .= "\n" . $e->getTraceAsString() ."\n";
                }
                if ( $cmdLine ) {