r36775 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r36774‎ | r36775 | r36776 >
Date:00:07, 29 June 2008
Author:demon
Status:old
Tags:
Comment:
(bug 14678) Make API respect $wgShowSQLErrors and $wgShowExceptionDetails. Patch by Max Semenik.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiMain.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiMain.php
@@ -314,14 +314,21 @@
315315 ApiResult :: setContent($errMessage, $this->makeHelpMsg());
316316
317317 } else {
 318+ global $wgShowSQLErrors, $wgShowExceptionDetails;
318319 //
319320 // Something is seriously wrong
320321 //
 322+ if ( ( $e instanceof DBQueryError ) && !$wgShowSQLErrors ) {
 323+ $info = "Database query error";
 324+ } else {
 325+ $info = "Exception Caught: {$e->getMessage()}";
 326+ }
 327+
321328 $errMessage = array (
322329 'code' => 'internal_api_error_'. get_class($e),
323 - 'info' => "Exception Caught: {$e->getMessage()}"
 330+ 'info' => $info,
324331 );
325 - ApiResult :: setContent($errMessage, "\n\n{$e->getTraceAsString()}\n\n");
 332+ ApiResult :: setContent($errMessage, $wgShowExceptionDetails ? "\n\n{$e->getTraceAsString()}\n\n" : "" );
326333 }
327334
328335 $this->getResult()->reset();
Index: trunk/phase3/RELEASE-NOTES
@@ -477,6 +477,7 @@
478478 * Added bkip parameter to list=blocks
479479 * (bug 14651) apprefix and similar parameters are now canonicalized
480480 * Added clprop=timestamp to prop=categories
 481+* (bug 14678) API errors now respects $wgShowExceptionDetails and $wgShowSQLErrors
481482
482483 === Languages updated in 1.13 ===
483484

Status & tagging log