From: Brad Jorsch Date: Mon, 29 Oct 2012 20:52:44 +0000 (-0400) Subject: (bug 41494) Honor $wgLogExceptionBacktrace in APIMain X-Git-Tag: 1.31.0-rc.0~21805^2 X-Git-Url: http://git.cyclocoop.org/%22.%28%24lien.?a=commitdiff_plain;h=ee6afa8b4e8ec84f220ffeadc105b18b26f8d4dc;p=lhc%2Fweb%2Fwiklou.git (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 --- 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.