(bug 14678) Make API respect $wgShowSQLErrors and $wgShowExceptionDetails. Patch...
authorChad Horohoe <demon@users.mediawiki.org>
Sun, 29 Jun 2008 00:07:13 +0000 (00:07 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Sun, 29 Jun 2008 00:07:13 +0000 (00:07 +0000)
RELEASE-NOTES
includes/api/ApiMain.php

index 0b0d8d2..efe386e 100644 (file)
@@ -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 ===
 
index 69124a1..798fa3f 100644 (file)
@@ -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();