From ab408b911d1447297cabef68c9352819a5a8141e Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Thu, 24 Feb 2011 15:51:51 +0000 Subject: [PATCH] Seems the api edit watch/unwatch wasn't too well tested (after it got poked a lot) 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 | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index babaf7844c..bd6f74e5f6 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -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; } } -- 2.20.1