r58237 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r58236‎ | r58237 | r58238 >
Date:00:56, 28 October 2009
Author:demon
Status:ok
Tags:
Comment:
(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
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/api/ApiBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiEditPage.php (modified) (history)
  • /trunk/phase3/includes/api/ApiParamInfo.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiEditPage.php
@@ -190,15 +190,9 @@
191191 }
192192 // Deprecated parameters
193193 if ($params['watch'])
194 - {
195194 $watch = true;
196 - $this->setWarning('The watch parameter has been deprecated.');
197 - }
198195 elseif ($params['unwatch'])
199 - {
200196 $watch = false;
201 - $this->setWarning('The unwatch parameter has been deprecated.');
202 - }
203197
204198 if($watch)
205199 $reqArr['wpWatchthis'] = '';
@@ -335,8 +329,14 @@
336330 'nocreate' => false,
337331 'captchaword' => null,
338332 'captchaid' => null,
339 - 'watch' => false,
340 - 'unwatch' => false,
 333+ 'watch' => array(
 334+ ApiBase :: PARAM_DFLT => false,
 335+ ApiBase :: PARAM_DEPRECATED => true,
 336+ ),
 337+ 'unwatch' => array(
 338+ ApiBase :: PARAM_DFLT => false,
 339+ ApiBase :: PARAM_DEPRECATED => true,
 340+ ),
341341 'watchlist' => array(
342342 ApiBase :: PARAM_DFLT => 'preferences',
343343 ApiBase :: PARAM_TYPE => array(
@@ -377,8 +377,8 @@
378378 'recreate' => 'Override any errors about the article having been deleted in the meantime',
379379 'createonly' => 'Don\'t edit the page if it exists already',
380380 'nocreate' => 'Throw an error if the page doesn\'t exist',
381 - 'watch' => 'DEPRECATED! Add the page to your watchlist',
382 - 'unwatch' => 'DEPRECATED! Remove the page from your watchlist',
 381+ 'watch' => 'Add the page to your watchlist',
 382+ 'unwatch' => 'Remove the page from your watchlist',
383383 'watchlist' => 'Unconditionally add or remove the page from your watchlist, use preferences or do not change watch',
384384 'captchaid' => 'CAPTCHA ID from previous request',
385385 'captchaword' => 'Answer to the CAPTCHA',
Index: trunk/phase3/includes/api/ApiBase.php
@@ -49,6 +49,7 @@
5050 const PARAM_MAX2 = 4; // Max value allowed for a parameter for bots and sysops. Only applies if TYPE='integer'
5151 const PARAM_MIN = 5; // Lowest value allowed for a parameter. Only applies if TYPE='integer'
5252 const PARAM_ALLOW_DUPLICATES = 6; // Boolean, do we allow the same value to be set more than once when ISMULTI=true
 53+ const PARAM_DEPRECATED = 7; // Boolean, is the parameter deprecated (will show a warning)
5354
5455 const LIMIT_BIG1 = 500; // Fast query, std user limit
5556 const LIMIT_BIG2 = 5000; // Fast query, bot/sysop limit
@@ -282,6 +283,11 @@
283284 if (is_array($desc))
284285 $desc = implode($paramPrefix, $desc);
285286
 287+ $deprecated = isset( $paramSettings[self :: PARAM_DEPRECATED] ) ?
 288+ $paramSettings[self :: PARAM_DEPRECATED] : false;
 289+ if( $deprecated )
 290+ $desc = "DEPRECATED! $desc";
 291+
286292 $type = isset($paramSettings[self :: PARAM_TYPE])? $paramSettings[self :: PARAM_TYPE] : null;
287293 if (isset ($type)) {
288294 if (isset ($paramSettings[self :: PARAM_ISMULTI]))
@@ -528,6 +534,7 @@
529535 $multi = isset ($paramSettings[self :: PARAM_ISMULTI]) ? $paramSettings[self :: PARAM_ISMULTI] : false;
530536 $type = isset ($paramSettings[self :: PARAM_TYPE]) ? $paramSettings[self :: PARAM_TYPE] : null;
531537 $dupes = isset ($paramSettings[self:: PARAM_ALLOW_DUPLICATES]) ? $paramSettings[self :: PARAM_ALLOW_DUPLICATES] : false;
 538+ $deprecated = isset ($paramSettings[self:: PARAM_DEPRECATED]) ? $paramSettings[self :: PARAM_DEPRECATED] : false;
532539
533540 // When type is not given, and no choices, the type is the same as $default
534541 if (!isset ($type)) {
@@ -621,6 +628,11 @@
622629 // Throw out duplicates if requested
623630 if (is_array($value) && !$dupes)
624631 $value = array_unique($value);
 632+
 633+ // Set a warning if a deprecated parameter has been passed
 634+ if( $deprecated ) {
 635+ $this->setWarning( "The $encParamName parameter has been deprecated." );
 636+ }
625637 }
626638
627639 return $value;
Index: trunk/phase3/includes/api/ApiParamInfo.php
@@ -114,6 +114,9 @@
115115 $a = array('name' => $n);
116116 if(isset($paramDesc[$n]))
117117 $a['description'] = implode("\n", (array)$paramDesc[$n]);
 118+ if(isset($p[ApiBase::PARAM_DEPRECATED]))
 119+ if($p[ApiBase::PARAM_DEPRECATED])
 120+ $a['deprecated'] = '';
118121 if(!is_array($p))
119122 {
120123 if(is_bool($p))
Index: trunk/phase3/RELEASE-NOTES
@@ -660,6 +660,7 @@
661661 * (bug 21105) list=usercontribs can now list contribs for User:0
662662 * (bug 21085) list=deletedrevs no longer returns only one revision when
663663 drcontinue param is passed
 664+* (bug 21106) Deprecated parameters now tagged in action=paraminfo
664665
665666 === Languages updated in 1.16 ===
666667

Follow-up revisions

RevisionCommit summaryAuthorDate
r58244Follow-up r58237: fixing PHP Notice: Undefined variable: deprecated in /var/w...raymond05:20, 28 October 2009

Status & tagging log