API: (bug 16422) Don't show help in format=jsonfm unless specifically requested with...
authorRoan Kattouw <catrope@users.mediawiki.org>
Tue, 28 Apr 2009 11:42:14 +0000 (11:42 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Tue, 28 Apr 2009 11:42:14 +0000 (11:42 +0000)
RELEASE-NOTES
includes/api/ApiFormatBase.php
includes/api/ApiFormatJson.php
includes/api/ApiMain.php

index fb5c84a..ed136a9 100644 (file)
@@ -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 ===
 
index 79fe42f..d5c8762 100644 (file)
@@ -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.
index 0159dbf..e89c867 100644 (file)
@@ -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 = "";
index 42aaacc..98c06b1 100644 (file)
@@ -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 {