Followup to r64197
authorSam Reed <reedy@users.mediawiki.org>
Sat, 27 Mar 2010 17:51:56 +0000 (17:51 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Sat, 27 Mar 2010 17:51:56 +0000 (17:51 +0000)
Remove the mutually exclusive else checks

Fix undefined on getWatchlistValue in ApiBase

includes/api/ApiBase.php
includes/api/ApiProtect.php
includes/api/ApiUndelete.php

index eaf07b9..f733765 100644 (file)
@@ -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;
        }
 
        /**
index bb32cda..4c0398e 100644 (file)
@@ -118,7 +118,7 @@ class ApiProtect extends ApiBase {
                
                if ( $params['watch'] || $watch ) {
                        $articleObj->doWatch();
-               } else if ( !$watch ) {
+               } else {
                        $articleObj->doUnwatch();
                }
 
index 46b0118..1fed5ca 100644 (file)
@@ -86,7 +86,7 @@ class ApiUndelete extends ApiBase {
                
                if ( $params['watch'] || $watch ) {
                        $wgUser->addWatch( $titleObj );
-               } else if ( !$watch ) {
+               } else {
                        $wgUser->removeWatch( $titleObj );
                }