Index: trunk/phase3/includes/api/ApiMove.php |
— | — | @@ -124,15 +124,23 @@ |
125 | 125 | |
126 | 126 | // Watch pages |
127 | 127 | $watch = $this->getWatchlistValue( $params['watchlist'], $titleObj ) || $wgUser->getOption( 'watchmoves' ); |
128 | | - |
| 128 | + |
129 | 129 | // Deprecated parameters |
130 | | - if ( $params['watch'] || $watch ) { |
131 | | - $wgUser->addWatch( $fromTitle ); |
132 | | - $wgUser->addWatch( $toTitle ); |
133 | | - } elseif ( $params['unwatch'] || !$watch ) { |
134 | | - $wgUser->removeWatch( $fromTitle ); |
135 | | - $wgUser->removeWatch( $toTitle ); |
| 130 | + if ( $params['watch'] ) { |
| 131 | + $watch = true; |
| 132 | + } elseif ( $params['unwatch'] ) { |
| 133 | + $watch = false; |
136 | 134 | } |
| 135 | + |
| 136 | + if ( $watch !== null ) { |
| 137 | + if ( $watch ) { |
| 138 | + $wgUser->addWatch( $fromTitle ); |
| 139 | + $wgUser->addWatch( $toTitle ); |
| 140 | + } else { |
| 141 | + $wgUser->removeWatch( $fromTitle ); |
| 142 | + $wgUser->removeWatch( $toTitle ); |
| 143 | + } |
| 144 | + } |
137 | 145 | $this->getResult()->addValue( null, $this->getModuleName(), $r ); |
138 | 146 | } |
139 | 147 | |
Index: trunk/phase3/includes/api/ApiProtect.php |
— | — | @@ -116,11 +116,17 @@ |
117 | 117 | |
118 | 118 | $watch = $this->getWatchlistValue( $params['watchlist'], $titleObj ); |
119 | 119 | |
120 | | - if ( $params['watch'] || $watch ) { |
121 | | - $articleObj->doWatch(); |
122 | | - } else { |
123 | | - $articleObj->doUnwatch(); |
| 120 | + if ( $params['watch'] ) { |
| 121 | + $watch = true; |
124 | 122 | } |
| 123 | + |
| 124 | + if ( $watch !== null ) { |
| 125 | + if ( $watch ) { |
| 126 | + $articleObj->doWatch(); |
| 127 | + } else { |
| 128 | + $articleObj->doUnwatch(); |
| 129 | + } |
| 130 | + } |
125 | 131 | |
126 | 132 | if ( $titleObj->exists() ) { |
127 | 133 | $ok = $articleObj->updateRestrictions( $protections, $params['reason'], $cascade, $expiryarray ); |
Index: trunk/phase3/includes/api/ApiRollback.php |
— | — | @@ -75,10 +75,12 @@ |
76 | 76 | |
77 | 77 | $watch = $this->getWatchlistValue( $params['watchlist'], $titleObj ); |
78 | 78 | |
79 | | - if ( $watch ) { |
80 | | - $articleObj->doWatch(); |
81 | | - } else if ( !$watch ) { |
82 | | - $articleObj->doUnwatch(); |
| 79 | + if ( $watch !== null) { |
| 80 | + if ( $watch ) { |
| 81 | + $articleObj->doWatch(); |
| 82 | + } else { |
| 83 | + $articleObj->doUnwatch(); |
| 84 | + } |
83 | 85 | } |
84 | 86 | |
85 | 87 | $info = array( |
Index: trunk/phase3/includes/api/ApiDelete.php |
— | — | @@ -85,11 +85,19 @@ |
86 | 86 | $watch = $this->getWatchlistValue( $params['watchlist'], $titleObj ) || $wgUser->getOption( 'watchdeletion' ); |
87 | 87 | |
88 | 88 | // Deprecated parameters |
89 | | - if ( $params['watch'] || $watch ) { |
90 | | - $articleObj->doWatch(); |
91 | | - } elseif ( $params['unwatch'] || !$watch ) { |
92 | | - $articleObj->doUnwatch(); |
| 89 | + if ( $params['watch'] ) { |
| 90 | + $watch = true; |
| 91 | + } elseif ( $params['unwatch'] ) { |
| 92 | + $watch = false; |
93 | 93 | } |
| 94 | + |
| 95 | + if ( $watch !== null ) { |
| 96 | + if ( $watch ) { |
| 97 | + $articleObj->doWatch(); |
| 98 | + } else { |
| 99 | + $articleObj->doUnwatch(); |
| 100 | + } |
| 101 | + } |
94 | 102 | } |
95 | 103 | |
96 | 104 | $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 ) { |
| 215 | + if ( $watch || $titleObj->userIsWatching() ) { |
216 | 216 | $reqArr['wpWatchthis'] = ''; |
217 | 217 | } |
218 | 218 | |
Index: trunk/phase3/includes/api/ApiUndelete.php |
— | — | @@ -84,10 +84,12 @@ |
85 | 85 | |
86 | 86 | $watch = $this->getWatchlistValue( $params['watchlist'], $titleObj ); |
87 | 87 | |
88 | | - if ( $params['watch'] || $watch ) { |
89 | | - $wgUser->addWatch( $titleObj ); |
90 | | - } else { |
91 | | - $wgUser->removeWatch( $titleObj ); |
| 88 | + if ( $watch !== null ) { |
| 89 | + if ( $watch ) { |
| 90 | + $wgUser->addWatch( $titleObj ); |
| 91 | + } else { |
| 92 | + $wgUser->removeWatch( $titleObj ); |
| 93 | + } |
92 | 94 | } |
93 | 95 | |
94 | 96 | $info['title'] = $titleObj->getPrefixedText(); |
Index: trunk/phase3/includes/api/ApiBase.php |
— | — | @@ -542,14 +542,14 @@ |
543 | 543 | case 'unwatch': |
544 | 544 | return false; |
545 | 545 | case 'preferences': |
546 | | - if ( $titleObj->exists() ) { |
547 | | - global $wgUser; |
548 | | - return $wgUser->getOption( 'watchdefault' ) || $titleObj->userIsWatching(); |
| 546 | + global $wgUser; |
| 547 | + if ( $titleObj->exists() && !$titleObj->userIsWatching() && $wgUser->getOption( 'watchdefault' ) ) { |
| 548 | + return true; |
549 | 549 | } |
550 | | - return false; |
| 550 | + return null; |
551 | 551 | case 'nochange': |
552 | 552 | default: |
553 | | - return $titleObj->userIsWatching(); |
| 553 | + return null; |
554 | 554 | } |
555 | 555 | } |
556 | 556 | |
Index: trunk/phase3/includes/api/ApiUpload.php |
— | — | @@ -239,10 +239,6 @@ |
240 | 240 | |
241 | 241 | $file = $this->mUpload->getLocalFile(); |
242 | 242 | |
243 | | - if ( !$watch ) { |
244 | | - $wgUser->removeWatch( $file->getTitle() ); |
245 | | - } |
246 | | - |
247 | 243 | $result['result'] = 'Success'; |
248 | 244 | $result['filename'] = $file->getName(); |
249 | 245 | $result['imageinfo'] = $this->mUpload->getImageInfo( $this->getResult() ); |
— | — | @@ -274,7 +270,6 @@ |
275 | 271 | ApiBase::PARAM_DFLT => 'preferences', |
276 | 272 | ApiBase::PARAM_TYPE => array( |
277 | 273 | 'watch', |
278 | | - 'unwatch', |
279 | 274 | 'preferences', |
280 | 275 | 'nochange' |
281 | 276 | ), |