From: Chad Horohoe Date: Sun, 29 Jun 2008 00:07:13 +0000 (+0000) Subject: (bug 14678) Make API respect $wgShowSQLErrors and $wgShowExceptionDetails. Patch... X-Git-Tag: 1.31.0-rc.0~46850 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=commitdiff_plain;h=e539d06170f20af887c04e2a939564ddb9ab07dc;p=lhc%2Fweb%2Fwiklou.git (bug 14678) Make API respect $wgShowSQLErrors and $wgShowExceptionDetails. Patch by Max Semenik. --- 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();