r68404 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68403‎ | r68404 | r68405 >
Date:12:10, 22 June 2010
Author:reedy
Status:ok
Tags:
Comment:
Resolve fixme of r66539

Move getWatchlistUser to ApiBase
Modified paths:
  • /trunk/phase3/includes/api/ApiBase.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryWatchlist.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryWatchlistRaw.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryWatchlistRaw.php
@@ -53,7 +53,7 @@
5454
5555 $params = $this->extractRequestParams();
5656
57 - $user = ApiQueryWatchlist::getWatchlistUser( $params );
 57+ $user = $this->getWatchlistUser( $params );
5858
5959 $prop = array_flip( (array)$params['prop'] );
6060 $show = array_flip( (array)$params['show'] );
Index: trunk/phase3/includes/api/ApiQueryWatchlist.php
@@ -57,7 +57,7 @@
5858
5959 $params = $this->extractRequestParams();
6060
61 - $user = ApiQueryWatchlist::getWatchlistUser( $params );
 61+ $user = $this->getWatchlistUser( $params );
6262
6363 if ( !is_null( $params['prop'] ) && is_null( $resultPageSet ) ) {
6464 $prop = array_flip( $params['prop'] );
@@ -258,7 +258,9 @@
259259 }
260260
261261 if ( $this->fld_notificationtimestamp ) {
262 - $vals['notificationtimestamp'] = ( $row->wl_notificationtimestamp == null ) ? '' : wfTimestamp( TS_ISO_8601, $row->wl_notificationtimestamp );
 262+ $vals['notificationtimestamp'] = ( $row->wl_notificationtimestamp == null )
 263+ ? ''
 264+ : wfTimestamp( TS_ISO_8601, $row->wl_notificationtimestamp );
263265 }
264266
265267 if ( $this->fld_comment && isset( $row->rc_comment ) ) {
@@ -273,30 +275,6 @@
274276 return $vals;
275277 }
276278
277 - /**
278 - * Gets the user for whom to get the watchlist
279 - *
280 - * @returns User
281 - */
282 - public static function getWatchlistUser( $params ) {
283 - global $wgUser;
284 - if ( !is_null( $params['owner'] ) && !is_null( $params['token'] ) ) {
285 - $user = User::newFromName( $params['owner'], false );
286 - if ( !$user->getId() ) {
287 - $this->dieUsage( 'Specified user does not exist', 'bad_wlowner' );
288 - }
289 - $token = $user->getOption( 'watchlisttoken' );
290 - if ( $token == '' || $token != $params['token'] ) {
291 - $this->dieUsage( 'Incorrect watchlist token provided -- please set a correct token in Special:Preferences', 'bad_wltoken' );
292 - }
293 - } elseif ( !$wgUser->isLoggedIn() ) {
294 - $this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' );
295 - } else {
296 - $user = $wgUser;
297 - }
298 - return $user;
299 - }
300 -
301279 public function getAllowedParams() {
302280 return array(
303281 'allrev' => false,
Index: trunk/phase3/includes/api/ApiBase.php
@@ -1083,6 +1083,30 @@
10841084 }
10851085
10861086 /**
 1087+ * Gets the user for whom to get the watchlist
 1088+ *
 1089+ * @returns User
 1090+ */
 1091+ public function getWatchlistUser( $params ) {
 1092+ global $wgUser;
 1093+ if ( !is_null( $params['owner'] ) && !is_null( $params['token'] ) ) {
 1094+ $user = User::newFromName( $params['owner'], false );
 1095+ if ( !$user->getId() ) {
 1096+ $this->dieUsage( 'Specified user does not exist', 'bad_wlowner' );
 1097+ }
 1098+ $token = $user->getOption( 'watchlisttoken' );
 1099+ if ( $token == '' || $token != $params['token'] ) {
 1100+ $this->dieUsage( 'Incorrect watchlist token provided -- please set a correct token in Special:Preferences', 'bad_wltoken' );
 1101+ }
 1102+ } elseif ( !$wgUser->isLoggedIn() ) {
 1103+ $this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' );
 1104+ } else {
 1105+ $user = $wgUser;
 1106+ }
 1107+ return $user;
 1108+ }
 1109+
 1110+ /**
10871111 * Returns a list of all possible errors returned by the module
10881112 * @return array in the format of array( key, param1, param2, ... ) or array( 'code' => ..., 'info' => ... )
10891113 */

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r66539* (bug 23548) Allow access of another users watchlist through watchlistraw us...reedy16:37, 16 May 2010

Status & tagging log