* Non-working API to facilitate dev collaboration. Do not enable this yet in localset...
[lhc/web/wiklou.git] / includes / Exception.php
index eeb4559..696454d 100644 (file)
@@ -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() {
@@ -40,6 +41,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 +75,10 @@ class MWException extends Exception
                if ( $wgCommandLineMode ) {
                        $this->reportText();
                } else {
+                       $log = $this->getLogMessage();
+                       if ( $log ) {
+                               wfDebugLog( 'exception', $log );
+                       }
                        $this->reportHTML();
                }
        }
@@ -94,6 +106,7 @@ class MWException extends Exception
        function htmlFooter() {
                echo "</body></html>";
        }
+
 }
 
 /**
@@ -181,8 +194,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 ) {}
        }