From: Sam Reed Date: Sat, 27 Mar 2010 17:51:56 +0000 (+0000) Subject: Followup to r64197 X-Git-Tag: 1.31.0-rc.0~37335 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=346554a2f3cc74948a6b158b3be591f3c2bf9caf;p=lhc%2Fweb%2Fwiklou.git Followup to r64197 Remove the mutually exclusive else checks Fix undefined on getWatchlistValue in ApiBase --- diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php index eaf07b9f49..f7337654e2 100644 --- a/includes/api/ApiBase.php +++ b/includes/api/ApiBase.php @@ -538,24 +538,20 @@ abstract class ApiBase { protected function getWatchlistValue ( $watchlist, $titleObj ) { switch ( $watchlist ) { case 'watch': - $watch = true; - break; + return true; case 'unwatch': - $watch = false; - break; - case 'preferences': - global $wgUser; - + return false; + case 'preferences': if ( $titleObj->exists() ) { - $watch = $wgUser->getOption( 'watchdefault' ) || $titleObj->userIsWatching(); + global $wgUser; + + return ($wgUser->getOption( 'watchdefault' ) || $titleObj->userIsWatching()); } - break; + return false; case 'nochange': default: - $watch = $titleObj->userIsWatching(); + return $titleObj->userIsWatching(); } - - return $watch; } /** diff --git a/includes/api/ApiProtect.php b/includes/api/ApiProtect.php index bb32cda636..4c0398e909 100644 --- a/includes/api/ApiProtect.php +++ b/includes/api/ApiProtect.php @@ -118,7 +118,7 @@ class ApiProtect extends ApiBase { if ( $params['watch'] || $watch ) { $articleObj->doWatch(); - } else if ( !$watch ) { + } else { $articleObj->doUnwatch(); } diff --git a/includes/api/ApiUndelete.php b/includes/api/ApiUndelete.php index 46b0118783..1fed5ca9f0 100644 --- a/includes/api/ApiUndelete.php +++ b/includes/api/ApiUndelete.php @@ -86,7 +86,7 @@ class ApiUndelete extends ApiBase { if ( $params['watch'] || $watch ) { $wgUser->addWatch( $titleObj ); - } else if ( !$watch ) { + } else { $wgUser->removeWatch( $titleObj ); }