From: Roan Kattouw Date: Tue, 28 Apr 2009 11:42:14 +0000 (+0000) Subject: API: (bug 16422) Don't show help in format=jsonfm unless specifically requested with... X-Git-Tag: 1.31.0-rc.0~41953 X-Git-Url: http://git.cyclocoop.org/data/%24self?a=commitdiff_plain;h=5811f0e27441094d5ee98af2a60523e1a4511fa0;p=lhc%2Fweb%2Fwiklou.git API: (bug 16422) Don't show help in format=jsonfm unless specifically requested with action=help --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index fb5c84a93e..ed136a90a3 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -434,6 +434,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 13049) "API must be accessed from the primary script entry point" error * (bug 18601) generator=backlinks returns invalid continue parameter * (bug 18597) Internal error with empty generator= parameter +* (bug 16422) Don't display help for format=jsonfm unless specifically requested === Languages updated in 1.15 === diff --git a/includes/api/ApiFormatBase.php b/includes/api/ApiFormatBase.php index 79fe42fe6a..d5c87626a8 100644 --- a/includes/api/ApiFormatBase.php +++ b/includes/api/ApiFormatBase.php @@ -100,6 +100,16 @@ abstract class ApiFormatBase extends ApiBase { public function getIsHtml() { return $this->mIsHtml; } + + /** + * Whether this formatter can format the help message in a nice way. + * By default, this returns the same as getIsHtml(). + * When action=help is set explicitly, the help will always be shown + * @return bool + */ + public function getWantsHelp() { + return $this->getIsHtml(); + } /** * Initialize the printer function and prepare the output headers, etc. diff --git a/includes/api/ApiFormatJson.php b/includes/api/ApiFormatJson.php index 0159dbf1dd..e89c867a9c 100644 --- a/includes/api/ApiFormatJson.php +++ b/includes/api/ApiFormatJson.php @@ -47,6 +47,11 @@ class ApiFormatJson extends ApiFormatBase { public function getNeedsRawData() { return $this->mIsRaw; } + + public function getWantsHelp() { + // Help is always ugly in JSON + return false; + } public function execute() { $prefix = $suffix = ""; diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index 42aaacc8c0..98c06b1563 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -311,7 +311,7 @@ class ApiMain extends ApiBase { 'info' => $e->getMessage()); // Only print the help message when this is for the developer, not runtime - if ($this->mPrinter->getIsHtml() || $this->mAction == 'help') + if ($this->mPrinter->getWantsHelp() || $this->mAction == 'help') ApiResult :: setContent($errMessage, $this->makeHelpMsg()); } else {