Index: trunk/phase3/includes/api/ApiMove.php |
— | — | @@ -125,15 +125,15 @@ |
126 | 126 | $watch = "preferences"; |
127 | 127 | if ( isset( $params['watchlist'] ) ) { |
128 | 128 | $watch = $params['watchlist']; |
129 | | - } elseif ( $wgUser->getOption( 'watchmoves' ) || $params['watch'] ) { |
| 129 | + } elseif ( $params['watch'] ) { |
130 | 130 | $watch = 'watch'; |
131 | 131 | } elseif ( $params['unwatch'] ) { |
132 | 132 | $watch = 'unwatch'; |
133 | 133 | } |
134 | 134 | |
135 | 135 | // Watch pages |
136 | | - $this->setWatch( $watch, $fromTitle ); |
137 | | - $this->setWatch( $watch, $toTitle ); |
| 136 | + $this->setWatch( $watch, $fromTitle, 'watchmoves' ); |
| 137 | + $this->setWatch( $watch, $toTitle, 'watchmoves' ); |
138 | 138 | |
139 | 139 | $this->getResult()->addValue( null, $this->getModuleName(), $r ); |
140 | 140 | } |
Index: trunk/phase3/includes/api/ApiDelete.php |
— | — | @@ -88,12 +88,10 @@ |
89 | 89 | $watch = 'watch'; |
90 | 90 | } elseif ( $params['unwatch'] ) { |
91 | 91 | $watch = 'unwatch'; |
92 | | - } elseif ( $wgUser->getOption( 'watchdeletion' ) ) { |
93 | | - $watch = 'watch'; |
94 | 92 | } else { |
95 | 93 | $watch = $params['watchlist']; |
96 | 94 | } |
97 | | - $this->setWatch( $watch, $titleObj ); |
| 95 | + $this->setWatch( $watch, $titleObj, 'watchdeletion' ); |
98 | 96 | } |
99 | 97 | |
100 | 98 | $r = array( 'title' => $titleObj->getPrefixedText(), 'reason' => $reason ); |
Index: trunk/phase3/includes/api/ApiEditPage.php |
— | — | @@ -211,7 +211,7 @@ |
212 | 212 | $watch = false; |
213 | 213 | } |
214 | 214 | |
215 | | - if ( $watch || $titleObj->userIsWatching() ) { |
| 215 | + if ( $watch ) { |
216 | 216 | $reqArr['wpWatchthis'] = ''; |
217 | 217 | } |
218 | 218 | |
Index: trunk/phase3/includes/api/ApiBase.php |
— | — | @@ -538,10 +538,12 @@ |
539 | 539 | /** |
540 | 540 | * Return true if we're to watch the page, false if not, null if no change. |
541 | 541 | * @param $watchlist String Valid values: 'watch', 'unwatch', 'preferences', 'nochange' |
542 | | - * @param $titleObj Title (optional) the page under consideration |
| 542 | + * @param $titleObj Title the page under consideration |
| 543 | + * @param $userOption The user option to consider when $watchlist=preferences. |
| 544 | + * If not set will magically default to either watchdefault or watchcreations |
543 | 545 | * @returns mixed |
544 | 546 | */ |
545 | | - protected function getWatchlistValue ( $watchlist, $titleObj = null ) { |
| 547 | + protected function getWatchlistValue ( $watchlist, $titleObj, $userOption = null ) { |
546 | 548 | switch ( $watchlist ) { |
547 | 549 | case 'watch': |
548 | 550 | return true; |
— | — | @@ -551,16 +553,17 @@ |
552 | 554 | |
553 | 555 | case 'preferences': |
554 | 556 | global $wgUser; |
555 | | - if ( isset($titleObj) && !$titleObj->userIsWatching() ) { |
556 | | - if ( $titleObj->exists() ) { |
557 | | - if ( $wgUser->getOption( 'watchdefault' ) ) { |
558 | | - return true; |
559 | | - } |
560 | | - } elseif ( $wgUser->getOption( 'watchcreations' ) ) { |
561 | | - return true; |
562 | | - } |
| 557 | + # If the user is already watching, don't bother checking |
| 558 | + if ( $titleObj->userIsWatching() ) { |
| 559 | + return null; |
563 | 560 | } |
564 | | - return null; |
| 561 | + # If no user option was passed, use watchdefault or watchcreation |
| 562 | + if ( is_null( $userOption ) ) { |
| 563 | + $userOption = $titleObj->exists() |
| 564 | + ? 'watchdefault' : 'watchcreations'; |
| 565 | + } |
| 566 | + # If the corresponding user option is true, watch, else no change |
| 567 | + return $wgUser->getOption( $userOption ) ? true : null; |
565 | 568 | |
566 | 569 | case 'nochange': |
567 | 570 | return null; |
— | — | @@ -574,10 +577,13 @@ |
575 | 578 | * Set a watch (or unwatch) based the based on a watchlist parameter. |
576 | 579 | * @param $watch String Valid values: 'watch', 'unwatch', 'preferences', 'nochange' |
577 | 580 | * @param $titleObj Title the article's title to change |
| 581 | + * @param $userOption The user option to consider when $watch=preferences |
578 | 582 | */ |
579 | | - protected function setWatch ( $watch, $titleObj ) { |
580 | | - $value = $this->getWatchlistValue( $watch, $titleObj ); |
581 | | - if( $value === null ) return; |
| 583 | + protected function setWatch ( $watch, $titleObj, $userOption = null ) { |
| 584 | + $value = $this->getWatchlistValue( $watch, $titleObj, $userOption ); |
| 585 | + if( $value === null ) { |
| 586 | + return; |
| 587 | + } |
582 | 588 | |
583 | 589 | $articleObj = new Article( $titleObj ); |
584 | 590 | if ( $value ) { |