From c660ee428f41ca04ff2ab96281bfbb36f6f4481c Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Wed, 28 Oct 2009 00:56:07 +0000 Subject: [PATCH] (bug 21106) tag deprecated parameter in action=paraminfo. Add new PARAM_DEPRECATED const for automagically tagging deprecated parameters. Keeps action=help and action=paraminfo up to date --- RELEASE-NOTES | 1 + includes/api/ApiBase.php | 12 ++++++++++++ includes/api/ApiEditPage.php | 20 ++++++++++---------- includes/api/ApiParamInfo.php | 3 +++ 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index aac8533b6c..3e0708ee9a 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 === diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index 79e7dcf36d..01e160467a 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -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; diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index bc2ede03fb..b6b21d5b35 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -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', diff --git a/includes/api/ApiParamInfo.php b/includes/api/ApiParamInfo.php index 403264b736..48b9feb817 100644 --- a/includes/api/ApiParamInfo.php +++ b/includes/api/ApiParamInfo.php @@ -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)) -- 2.20.1