Page MenuHomePhabricator

HideQuery.patch

Authored By
bzimport
Nov 21 2014, 10:12 PM
Size
1 KB
Referenced Files
None
Subscribers
None

HideQuery.patch

Index: includes/api/ApiMain.php
===================================================================
--- includes/api/ApiMain.php (revision 36771)
+++ includes/api/ApiMain.php (working copy)
@@ -288,6 +288,7 @@
* Returns the error code
*/
protected function substituteResultWithError($e) {
+ global $wgShowSQLErrors, $wgShowExceptionDetails;
// Printer may not be initialized if the extractRequestParams() fails for the main module
if (!isset ($this->mPrinter)) {
@@ -317,11 +318,18 @@
//
// 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();

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4499
Default Alt Text
HideQuery.patch (1 KB)

Event Timeline