From: Bryan Tong Minh Date: Tue, 14 Jul 2009 20:48:00 +0000 (+0000) Subject: (bug 19090) Added watchlist parameter, deprecated watch and unwatch parameter in... X-Git-Tag: 1.31.0-rc.0~40956 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=f5137ba6267f2f80c5da520a7e9aff35915cd490;p=lhc%2Fweb%2Fwiklou.git (bug 19090) Added watchlist parameter, deprecated watch and unwatch parameter in action=edit --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index e9fc5c3aaa..6c3fdb13f1 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -296,6 +296,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 19528) Added XSLT parameter to API queries in format=xml * (bug 19040) Fix prependtext and appendtext in combination with section parameter in action=edit +* (bug 19090) Added watchlist parameter, deprecated watch and unwatch + parameter in action=edit === Languages updated in 1.16 === diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index d46b1f0f44..6475f36d03 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -169,18 +169,37 @@ class ApiEditPage extends ApiBase { else $reqArr['wpSection'] = ''; - if($params['watch']) - $watch = true; - else if($params['unwatch']) - $watch = false; - else if($titleObj->userIsWatching()) - $watch = true; - else if($wgUser->getOption('watchdefault')) - $watch = true; - else if($wgUser->getOption('watchcreations') && !$titleObj->exists()) + // Handle watchlist settings + switch ($params['watchlist']) + { + case 'watch': + $watch = true; + break; + case 'unwatch': + $watch = false; + break; + case 'preferences': + if ($titleObj->exists()) + $watch = $wgUser->getOption('watchdefault'); + else + $watch = $wgUser->getOption('watchcreations'); + break; + case 'nochange': + default: + $watch = $titleObj->userIsWatching(); + } + // Deprecated parameters + if ($params['watch']) + { $watch = true; - else + $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'] = ''; @@ -318,6 +337,15 @@ class ApiEditPage extends ApiBase { 'captchaid' => null, 'watch' => false, 'unwatch' => false, + 'watchlist' => array( + ApiBase :: PARAM_DFLT => 'preferences', + ApiBase :: PARAM_TYPE => array( + 'watch', + 'unwatch', + 'preferences', + 'nochange' + ), + ), 'md5' => null, 'prependtext' => null, 'appendtext' => null, @@ -349,8 +377,9 @@ 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' => 'Add the page to your watchlist', - 'unwatch' => 'Remove the page from your watchlist', + 'watch' => 'DEPRECATED! Add the page to your watchlist', + 'unwatch' => 'DEPRECATED! 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', 'md5' => array( 'The MD5 hash of the text parameter, or the prependtext and appendtext parameters concatenated.',