From e539d06170f20af887c04e2a939564ddb9ab07dc Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Sun, 29 Jun 2008 00:07:13 +0000 Subject: [PATCH] (bug 14678) Make API respect $wgShowSQLErrors and $wgShowExceptionDetails. Patch by Max Semenik. --- RELEASE-NOTES | 1 + includes/api/ApiMain.php | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 0b0d8d2c54..efe386e355 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -477,6 +477,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Added bkip parameter to list=blocks * (bug 14651) apprefix and similar parameters are now canonicalized * Added clprop=timestamp to prop=categories +* (bug 14678) API errors now respects $wgShowExceptionDetails and $wgShowSQLErrors === Languages updated in 1.13 === diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 69124a1650..798fa3f996 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -314,14 +314,21 @@ class ApiMain extends ApiBase { ApiResult :: setContent($errMessage, $this->makeHelpMsg()); } else { + global $wgShowSQLErrors, $wgShowExceptionDetails; // // Something is seriously wrong // + if ( ( $e instanceof DBQueryError ) && !$wgShowSQLErrors ) { + $info = "Database query error"; + } else { + $info = "Exception Caught: {$e->getMessage()}"; + } + $errMessage = array ( 'code' => 'internal_api_error_'. get_class($e), - 'info' => "Exception Caught: {$e->getMessage()}" + 'info' => $info, ); - ApiResult :: setContent($errMessage, "\n\n{$e->getTraceAsString()}\n\n"); + ApiResult :: setContent($errMessage, $wgShowExceptionDetails ? "\n\n{$e->getTraceAsString()}\n\n" : "" ); } $this->getResult()->reset(); -- 2.20.1