(bug 41494) Honor $wgLogExceptionBacktrace in APIMain
authorBrad Jorsch <anomie.wikipedia@gmail.com>
Mon, 29 Oct 2012 20:52:44 +0000 (16:52 -0400)
committerBrad Jorsch <anomie.wikipedia@gmail.com>
Mon, 29 Oct 2012 20:52:44 +0000 (16:52 -0400)
When the API catches a non-API exception, it logs the message but does
not record the backtrace. It should honor $wgLogExceptionBacktrace
(added in 1.20) to decide whether to log the backtrace or just the
message.

Change-Id: I33fcbebd0e41dc2fda0cd00f8779e013300c0494

RELEASE-NOTES-1.21
includes/api/ApiMain.php

index 74ff05b..3357686 100644 (file)
@@ -54,6 +54,8 @@ production.
   disabled, and don't wrap HTML-syntax definition lists in paragraphs.
 * (bug 41409) Diffs while editing an old revision should again diff against the
   current revision.
+* (bug 41494) Honor $wgLogExceptionBacktrace when logging non-API exceptions
+  caught during API execution.
 
 === API changes in 1.21 ===
 * prop=revisions can now report the contentmodel and contentformat, see docs/contenthandler.txt
index a399c1e..91b8cc8 100644 (file)
@@ -376,7 +376,12 @@ class ApiMain extends ApiBase {
 
                        // Log it
                        if ( !( $e instanceof UsageException ) ) {
-                               wfDebugLog( 'exception', $e->getLogMessage() );
+                               global $wgLogExceptionBacktrace;
+                               if ( $wgLogExceptionBacktrace ) {
+                                       wfDebugLog( 'exception', $e->getLogMessage() . "\n" . $e->getTraceAsString() . "\n" );
+                               } else {
+                                       wfDebugLog( 'exception', $e->getLogMessage() );
+                               }
                        }
 
                        // Handle any kind of exception by outputing properly formatted error message.