From ee6afa8b4e8ec84f220ffeadc105b18b26f8d4dc Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Mon, 29 Oct 2012 16:52:44 -0400 Subject: [PATCH] (bug 41494) Honor $wgLogExceptionBacktrace in APIMain 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 | 2 ++ includes/api/ApiMain.php | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES-1.21 b/RELEASE-NOTES-1.21 index 74ff05bf8d..3357686415 100644 --- a/RELEASE-NOTES-1.21 +++ b/RELEASE-NOTES-1.21 @@ -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 diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index a399c1ebff..91b8cc834b 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -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. -- 2.20.1