(bug 19090) Added watchlist parameter, deprecated watch and unwatch parameter in...
authorBryan Tong Minh <btongminh@users.mediawiki.org>
Tue, 14 Jul 2009 20:48:00 +0000 (20:48 +0000)
committerBryan Tong Minh <btongminh@users.mediawiki.org>
Tue, 14 Jul 2009 20:48:00 +0000 (20:48 +0000)
RELEASE-NOTES
includes/api/ApiEditPage.php

index e9fc5c3..6c3fdb1 100644 (file)
@@ -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 ===
 
index d46b1f0..6475f36 100644 (file)
@@ -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.',