API: Mark seldom-used formats as deprecated
[lhc/web/wiklou.git] / includes / api / ApiFormatBase.php
index 848d129..2e3fc11 100644 (file)
@@ -52,7 +52,7 @@ abstract class ApiFormatBase extends ApiBase {
        }
 
        /**
-        * Overriding class returns the mime type that should be sent to the client.
+        * Overriding class returns the MIME type that should be sent to the client.
         * This method is not called if getIsHtml() returns true.
         * @return string
         */
@@ -338,6 +338,18 @@ See the <a href='https://www.mediawiki.org/wiki/API'>complete documentation</a>,
        public function getDescription() {
                return $this->getIsHtml() ? ' (pretty-print in HTML)' : '';
        }
+
+       /**
+        * To avoid code duplication with the deprecation of dbg, dump, txt, wddx,
+        * and yaml, this method is added to do the necessary work. It should be
+        * removed when those deprecated formats are removed.
+        */
+       protected function markDeprecated() {
+               $fm = $this->getIsHtml() ? 'fm' : '';
+               $name = $this->getModuleName();
+               $this->logFeatureUsage( "format=$name" );
+               $this->setWarning( "format=$name has been deprecated. Please use format=json$fm instead." );
+       }
 }
 
 /**
@@ -354,7 +366,7 @@ class ApiFormatFeedWrapper extends ApiFormatBase {
         * Call this method to initialize output data. See execute()
         * @param ApiResult $result
         * @param object $feed An instance of one of the $wgFeedClasses classes
-        * @param array $feedItems of FeedItem objects
+        * @param array $feedItems Array of FeedItem objects
         */
        public static function setResult( $result, $feed, $feedItems ) {
                // Store output in the Result data.