r64267 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r64266‎ | r64267 | r64268 >
Date:17:51, 27 March 2010
Author:reedy
Status:ok
Tags:
Comment:
Followup to r64197

Remove the mutually exclusive else checks

Fix undefined on getWatchlistValue in ApiBase
Modified paths:
  • /trunk/phase3/includes/api/ApiBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiProtect.php (modified) (history)
  • /trunk/phase3/includes/api/ApiUndelete.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiProtect.php
@@ -118,7 +118,7 @@
119119
120120 if ( $params['watch'] || $watch ) {
121121 $articleObj->doWatch();
122 - } else if ( !$watch ) {
 122+ } else {
123123 $articleObj->doUnwatch();
124124 }
125125
Index: trunk/phase3/includes/api/ApiUndelete.php
@@ -86,7 +86,7 @@
8787
8888 if ( $params['watch'] || $watch ) {
8989 $wgUser->addWatch( $titleObj );
90 - } else if ( !$watch ) {
 90+ } else {
9191 $wgUser->removeWatch( $titleObj );
9292 }
9393
Index: trunk/phase3/includes/api/ApiBase.php
@@ -538,24 +538,20 @@
539539 protected function getWatchlistValue ( $watchlist, $titleObj ) {
540540 switch ( $watchlist ) {
541541 case 'watch':
542 - $watch = true;
543 - break;
 542+ return true;
544543 case 'unwatch':
545 - $watch = false;
546 - break;
547 - case 'preferences':
548 - global $wgUser;
549 -
 544+ return false;
 545+ case 'preferences':
550546 if ( $titleObj->exists() ) {
551 - $watch = $wgUser->getOption( 'watchdefault' ) || $titleObj->userIsWatching();
 547+ global $wgUser;
 548+
 549+ return ($wgUser->getOption( 'watchdefault' ) || $titleObj->userIsWatching());
552550 }
553 - break;
 551+ return false;
554552 case 'nochange':
555553 default:
556 - $watch = $titleObj->userIsWatching();
 554+ return $titleObj->userIsWatching();
557555 }
558 -
559 - return $watch;
560556 }
561557
562558 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r64275Fix coding style, whitespace in r64267catrope21:34, 27 March 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r64197Fix bug 22944 in a much better fashion (using watchlist parameter)...reedy22:15, 25 March 2010

Status & tagging log