Index: branches/REL1_17/phase3/includes/Article.php |
— | — | @@ -2424,6 +2424,9 @@ |
2425 | 2425 | |
2426 | 2426 | /** |
2427 | 2427 | * Add this page to $wgUser's watchlist |
| 2428 | + * |
| 2429 | + * This is safe to be called multiple times |
| 2430 | + * |
2428 | 2431 | * @return bool true on successful watch operation |
2429 | 2432 | */ |
2430 | 2433 | public function doWatch() { |
Property changes on: branches/REL1_17/phase3/includes/Article.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
2431 | 2434 | Merged /trunk/phase3/includes/Article.php:r82727,82729 |
Index: branches/REL1_17/phase3/includes/api/ApiBase.php |
— | — | @@ -576,9 +576,12 @@ |
577 | 577 | * @param $titleObj Title the page under consideration |
578 | 578 | * @param $userOption String The user option to consider when $watchlist=preferences. |
579 | 579 | * If not set will magically default to either watchdefault or watchcreations |
580 | | - * @returns mixed |
| 580 | + * @returns Boolean |
581 | 581 | */ |
582 | 582 | protected function getWatchlistValue ( $watchlist, $titleObj, $userOption = null ) { |
| 583 | + |
| 584 | + $userWatching = $titleObj->userIsWatching(); |
| 585 | + |
583 | 586 | global $wgUser; |
584 | 587 | switch ( $watchlist ) { |
585 | 588 | case 'watch': |
— | — | @@ -589,22 +592,22 @@ |
590 | 593 | |
591 | 594 | case 'preferences': |
592 | 595 | # If the user is already watching, don't bother checking |
593 | | - if ( $titleObj->userIsWatching() ) { |
594 | | - return null; |
| 596 | + if ( $userWatching ) { |
| 597 | + return true; |
595 | 598 | } |
596 | 599 | # If no user option was passed, use watchdefault or watchcreation |
597 | 600 | if ( is_null( $userOption ) ) { |
598 | 601 | $userOption = $titleObj->exists() |
599 | 602 | ? 'watchdefault' : 'watchcreations'; |
600 | 603 | } |
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 ); |
603 | 606 | |
604 | 607 | case 'nochange': |
605 | | - return null; |
| 608 | + return $userWatching; |
606 | 609 | |
607 | 610 | default: |
608 | | - return null; |
| 611 | + return $userWatching; |
609 | 612 | } |
610 | 613 | } |
611 | 614 | |