Seems the api edit watch/unwatch wasn't too well tested (after it got poked a lot)
authorSam Reed <reedy@users.mediawiki.org>
Thu, 24 Feb 2011 15:51:51 +0000 (15:51 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Thu, 24 Feb 2011 15:51:51 +0000 (15:51 +0000)
EditPage::commitWatch() unconditionally  does a watch/unwatch...

And multiple watches of a watched page end up with an INSERT IGNORE, so not a big deal

includes/api/ApiBase.php

index babaf78..bd6f74e 100644 (file)
@@ -578,9 +578,12 @@ abstract class ApiBase {
         * @param $titleObj Title the page under consideration
         * @param $userOption String The user option to consider when $watchlist=preferences.
         *      If not set will magically default to either watchdefault or watchcreations
-        * @returns mixed
+        * @returns Boolean
         */
        protected function getWatchlistValue ( $watchlist, $titleObj, $userOption = null ) {
+
+               $userWatching = $titleObj->userIsWatching();
+
                global $wgUser;
                switch ( $watchlist ) {
                        case 'watch':
@@ -591,22 +594,22 @@ abstract class ApiBase {
 
                        case 'preferences':
                                # If the user is already watching, don't bother checking
-                               if ( $titleObj->userIsWatching() ) {
-                                       return null;
+                               if ( $userWatching ) {
+                                       return true;
                                }
                                # If no user option was passed, use watchdefault or watchcreation
                                if ( is_null( $userOption ) ) {
                                        $userOption = $titleObj->exists()
                                                ? 'watchdefault' : 'watchcreations';
                                }
-                               # If the corresponding user option is true, watch, else no change
-                               return $wgUser->getOption( $userOption ) ? true : null;
+                               # If the corresponding user option is true, watch, don't
+                               return $wgUser->getOption( $userOption ) ? true : false;
 
                        case 'nochange':
-                               return null;
+                               return $userWatching;
 
                        default:
-                               return null;
+                               return $userWatching;
                }
        }