r82730 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r82729‎ | r82730 | r82731 >
Date:16:03, 24 February 2011
Author:reedy
Status:ok
Tags:
Comment:
MFT r82727, 82729
Modified paths:
  • /branches/REL1_17/phase3/includes/Article.php (modified) (history)
  • /branches/REL1_17/phase3/includes/api/ApiBase.php (modified) (history)

Diff [purge]

Index: branches/REL1_17/phase3/includes/Article.php
@@ -2424,6 +2424,9 @@
24252425
24262426 /**
24272427 * Add this page to $wgUser's watchlist
 2428+ *
 2429+ * This is safe to be called multiple times
 2430+ *
24282431 * @return bool true on successful watch operation
24292432 */
24302433 public function doWatch() {
Property changes on: branches/REL1_17/phase3/includes/Article.php
___________________________________________________________________
Modified: svn:mergeinfo
24312434 Merged /trunk/phase3/includes/Article.php:r82727,82729
Index: branches/REL1_17/phase3/includes/api/ApiBase.php
@@ -576,9 +576,12 @@
577577 * @param $titleObj Title the page under consideration
578578 * @param $userOption String The user option to consider when $watchlist=preferences.
579579 * If not set will magically default to either watchdefault or watchcreations
580 - * @returns mixed
 580+ * @returns Boolean
581581 */
582582 protected function getWatchlistValue ( $watchlist, $titleObj, $userOption = null ) {
 583+
 584+ $userWatching = $titleObj->userIsWatching();
 585+
583586 global $wgUser;
584587 switch ( $watchlist ) {
585588 case 'watch':
@@ -589,22 +592,22 @@
590593
591594 case 'preferences':
592595 # If the user is already watching, don't bother checking
593 - if ( $titleObj->userIsWatching() ) {
594 - return null;
 596+ if ( $userWatching ) {
 597+ return true;
595598 }
596599 # If no user option was passed, use watchdefault or watchcreation
597600 if ( is_null( $userOption ) ) {
598601 $userOption = $titleObj->exists()
599602 ? 'watchdefault' : 'watchcreations';
600603 }
601 - # If the corresponding user option is true, watch, else no change
602 - return $wgUser->getOption( $userOption ) ? true : null;
 604+ # Watch the article based on the user preference
 605+ return (bool)$wgUser->getOption( $userOption );
603606
604607 case 'nochange':
605 - return null;
 608+ return $userWatching;
606609
607610 default:
608 - return null;
 611+ return $userWatching;
609612 }
610613 }
611614

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r82727Seems the api edit watch/unwatch wasn't too well tested (after it got poked a...reedy15:51, 24 February 2011
r82729Followup r82727, improve comments, cast return value to boolreedy16:00, 24 February 2011

Status & tagging log