(bug 21106) tag deprecated parameter in action=paraminfo. Add new PARAM_DEPRECATED...
authorChad Horohoe <demon@users.mediawiki.org>
Wed, 28 Oct 2009 00:56:07 +0000 (00:56 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Wed, 28 Oct 2009 00:56:07 +0000 (00:56 +0000)
RELEASE-NOTES
includes/api/ApiBase.php
includes/api/ApiEditPage.php
includes/api/ApiParamInfo.php

index aac8533..3e0708e 100644 (file)
@@ -660,6 +660,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 21105) list=usercontribs can now list contribs for User:0
 * (bug 21085) list=deletedrevs no longer returns only one revision when
   drcontinue param is passed
+* (bug 21106) Deprecated parameters now tagged in action=paraminfo
 
 === Languages updated in 1.16 ===
 
index 79e7dcf..01e1604 100644 (file)
@@ -49,6 +49,7 @@ abstract class ApiBase {
        const PARAM_MAX2 = 4; // Max value allowed for a parameter for bots and sysops. Only applies if TYPE='integer'
        const PARAM_MIN = 5; // Lowest value allowed for a parameter. Only applies if TYPE='integer'
        const PARAM_ALLOW_DUPLICATES = 6; // Boolean, do we allow the same value to be set more than once when ISMULTI=true
+       const PARAM_DEPRECATED = 7; // Boolean, is the parameter deprecated (will show a warning)
 
        const LIMIT_BIG1 = 500; // Fast query, std user limit
        const LIMIT_BIG2 = 5000; // Fast query, bot/sysop limit
@@ -282,6 +283,11 @@ abstract class ApiBase {
                                if (is_array($desc))
                                        $desc = implode($paramPrefix, $desc);
 
+                               $deprecated = isset( $paramSettings[self :: PARAM_DEPRECATED] ) ? 
+                                       $paramSettings[self :: PARAM_DEPRECATED] : false;
+                               if( $deprecated )
+                                       $desc = "DEPRECATED! $desc";    
+
                                $type = isset($paramSettings[self :: PARAM_TYPE])? $paramSettings[self :: PARAM_TYPE] : null;
                                if (isset ($type)) {
                                        if (isset ($paramSettings[self :: PARAM_ISMULTI]))
@@ -528,6 +534,7 @@ abstract class ApiBase {
                        $multi = isset ($paramSettings[self :: PARAM_ISMULTI]) ? $paramSettings[self :: PARAM_ISMULTI] : false;
                        $type = isset ($paramSettings[self :: PARAM_TYPE]) ? $paramSettings[self :: PARAM_TYPE] : null;
                        $dupes = isset ($paramSettings[self:: PARAM_ALLOW_DUPLICATES]) ? $paramSettings[self :: PARAM_ALLOW_DUPLICATES] : false;
+                       $deprecated = isset ($paramSettings[self:: PARAM_DEPRECATED]) ? $paramSettings[self :: PARAM_DEPRECATED] : false;
 
                        // When type is not given, and no choices, the type is the same as $default
                        if (!isset ($type)) {
@@ -621,6 +628,11 @@ abstract class ApiBase {
                        // Throw out duplicates if requested
                        if (is_array($value) && !$dupes)
                                $value = array_unique($value);
+                               
+                       // Set a warning if a deprecated parameter has been passed
+                       if( $deprecated ) {
+                               $this->setWarning( "The $encParamName parameter has been deprecated." );
+                       }
                }
 
                return $value;
index bc2ede0..b6b21d5 100644 (file)
@@ -190,15 +190,9 @@ class ApiEditPage extends ApiBase {
                }
                // Deprecated parameters
                if ($params['watch']) 
-               {
                        $watch = true;
-                       $this->setWarning('The watch parameter has been deprecated.');
-               }
                elseif ($params['unwatch']) 
-               {
                        $watch = false;
-                       $this->setWarning('The unwatch parameter has been deprecated.');
-               }
                
                if($watch)
                        $reqArr['wpWatchthis'] = '';
@@ -335,8 +329,14 @@ class ApiEditPage extends ApiBase {
                        'nocreate' => false,
                        'captchaword' => null,
                        'captchaid' => null,
-                       'watch' => false,
-                       'unwatch' => false,
+                       'watch' => array(
+                               ApiBase :: PARAM_DFLT => false,
+                               ApiBase :: PARAM_DEPRECATED => true,
+                       ),
+                       'unwatch' => array(
+                               ApiBase :: PARAM_DFLT => false,
+                               ApiBase :: PARAM_DEPRECATED => true,
+                       ),
                        'watchlist' => array(
                                ApiBase :: PARAM_DFLT => 'preferences',
                                ApiBase :: PARAM_TYPE => array(
@@ -377,8 +377,8 @@ class ApiEditPage extends ApiBase {
                        'recreate' => 'Override any errors about the article having been deleted in the meantime',
                        'createonly' => 'Don\'t edit the page if it exists already',
                        'nocreate' => 'Throw an error if the page doesn\'t exist',
-                       'watch' => 'DEPRECATED! Add the page to your watchlist',
-                       'unwatch' => 'DEPRECATED! Remove the page from your watchlist',
+                       'watch' => 'Add the page to your watchlist',
+                       'unwatch' => 'Remove the page from your watchlist',
                        'watchlist' => 'Unconditionally add or remove the page from your watchlist, use preferences or do not change watch',
                        'captchaid' => 'CAPTCHA ID from previous request',
                        'captchaword' => 'Answer to the CAPTCHA',
index 403264b..48b9feb 100644 (file)
@@ -114,6 +114,9 @@ class ApiParamInfo extends ApiBase {
                        $a = array('name' => $n);
                        if(isset($paramDesc[$n]))
                                $a['description'] = implode("\n", (array)$paramDesc[$n]);
+                       if(isset($p[ApiBase::PARAM_DEPRECATED]))
+                               if($p[ApiBase::PARAM_DEPRECATED])
+                                       $a['deprecated'] = '';
                        if(!is_array($p))
                        {
                                if(is_bool($p))