Merge "exception: Use MWExceptionHandler::logException in more places"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 31 Oct 2013 13:58:30 +0000 (13:58 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 31 Oct 2013 13:58:30 +0000 (13:58 +0000)
includes/DeferredUpdates.php
includes/Exception.php
includes/Wiki.php
includes/api/ApiMain.php
includes/db/DatabaseError.php
includes/job/JobQueueGroup.php

index a321414..c385f13 100644 (file)
@@ -109,7 +109,7 @@ class DeferredUpdates {
                                // be reported to the user since the output is already sent.
                                // Instead we just log them.
                                if ( !$e instanceof ErrorPageError ) {
-                                       wfDebugLog( 'exception', $e->getLogMessage() );
+                                       MWExceptionHandler::logException( $e );
                                }
                        }
                }
index 46402f9..582ad93 100644 (file)
@@ -43,6 +43,16 @@ class MWException extends Exception {
                        !empty( $GLOBALS['wgTitle'] );
        }
 
+       /**
+        * Whether to log this exception in the exception debug log.
+        *
+        * @since 1.23
+        * @return boolean
+        */
+       function isLoggable() {
+               return true;
+       }
+
        /**
         * Can the extension use the Message class/wfMessage to get i18n-ed messages?
         *
@@ -801,8 +811,8 @@ class MWExceptionHandler {
        public static function logException( Exception $e ) {
                global $wgLogExceptionBacktrace;
 
-               $log = self::getLogMessage( $e );
-               if ( $log ) {
+               if ( !( $e instanceof MWException ) || $e->isLoggable() ) {
+                       $log = self::getLogMessage( $e );
                        if ( $wgLogExceptionBacktrace ) {
                                wfDebugLog( 'exception', $log . "\n" . self::formatRedactedTrace( $e ) . "\n" );
                        } else {
index 403ef11..08567ee 100644 (file)
@@ -688,7 +688,7 @@ class MediaWiki {
                                // We don't want exceptions thrown during job execution to
                                // be reported to the user since the output is already sent.
                                // Instead we just log them.
-                               wfDebugLog( 'exception', $e->getLogMessage() );
+                               MWExceptionHandler::logException( $e );
                        }
                }
        }
index c10d85c..c11f16c 100644 (file)
@@ -383,13 +383,8 @@ class ApiMain extends ApiBase {
                        wfRunHooks( 'ApiMain::onException', array( $this, $e ) );
 
                        // Log it
-                       if ( $e instanceof MWException && !( $e instanceof UsageException ) ) {
-                               global $wgLogExceptionBacktrace;
-                               if ( $wgLogExceptionBacktrace ) {
-                                       wfDebugLog( 'exception', $e->getLogMessage() . "\n" . $e->getTraceAsString() . "\n" );
-                               } else {
-                                       wfDebugLog( 'exception', $e->getLogMessage() );
-                               }
+                       if ( !( $e instanceof UsageException ) ) {
+                               MWExceptionHandler::logException( $e );
                        }
 
                        // Handle any kind of exception by outputting properly formatted error message.
index 937bea0..f14a502 100644 (file)
@@ -133,10 +133,10 @@ class DBConnectionError extends DBError {
        }
 
        /**
-        * @return bool
+        * @return boolean
         */
-       function getLogMessage() {
-               // Don't send to the exception log
+       function isLoggable() {
+               // Don't send to the exception log, already in dberror log
                return false;
        }
 
@@ -310,15 +310,15 @@ class DBQueryError extends DBError {
        }
 
        /**
-        * @return bool
+        * @return boolean
         */
-       function getLogMessage() {
-               # Don't send to the exception log
+       function isLoggable() {
+               // Don't send to the exception log, already in dberror log
                return false;
        }
 
        /**
-        * @return String
+        * @return string
         */
        function getPageTitle() {
                return $this->msg( 'databaseerror', 'Database error' );
index a20ea4a..fa7fee5 100644 (file)
@@ -376,7 +376,7 @@ class JobQueueGroup {
                                                        ++$count;
                                                }
                                        } catch ( JobQueueError $e ) {
-                                               wfDebugLog( 'exception', $e->getLogMessage() );
+                                               MWExceptionHandler::logException( $e );
                                        }
                                }
                        }