From: Sam Reed Date: Thu, 24 Feb 2011 15:51:51 +0000 (+0000) Subject: Seems the api edit watch/unwatch wasn't too well tested (after it got poked a lot) X-Git-Tag: 1.31.0-rc.0~31793 X-Git-Url: http://git.cyclocoop.org/%24href?a=commitdiff_plain;h=ab408b911d1447297cabef68c9352819a5a8141e;p=lhc%2Fweb%2Fwiklou.git 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 --- 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; } }