r53782 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53781‎ | r53782 | r53783 >
Date:17:04, 26 July 2009
Author:simetrical
Status:deferred (Comments)
Tags:
Comment:
Don't overload wluser parameter, use new wlowner

Fix for r53703 based on code review by Roan. Also improved error
message and sample documentation slightly.
Modified paths:
  • /trunk/phase3/includes/api/ApiFeedWatchlist.php (modified) (history)
  • /trunk/phase3/includes/api/ApiQueryWatchlist.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/api/ApiQueryWatchlist.php
@@ -58,11 +58,11 @@
5959
6060 $params = $this->extractRequestParams();
6161
62 - if (!is_null($params['user']) && !is_null($params['token'])) {
63 - $user = User::newFromName($params['user']);
 62+ if (!is_null($params['owner']) && !is_null($params['token'])) {
 63+ $user = User::newFromName($params['owner']);
6464 $token = $user->getOption('watchlisttoken');
6565 if ($token == '' || $token != $params['token']) {
66 - $this->dieUsage('Incorrect watchlist token provided', 'bad_wltoken');
 66+ $this->dieUsage('Incorrect watchlist token provided -- please set a correct token in Special:Preferences', 'bad_wltoken');
6767 }
6868 } elseif (!$wgUser->isLoggedIn()) {
6969 $this->dieUsage('You must be logged-in to have a watchlist', 'notloggedin');
@@ -173,16 +173,12 @@
174174 $this->addWhereIf('rc_patrolled != 0', isset($show['patrolled']));
175175 }
176176
177 - # Ignore extra user conditions if we're using token mode, since the
178 - # user was already manually specified.
179 - if(is_null($params['user']) || is_null($params['token'])) {
180 - if(!is_null($params['user']) && !is_null($params['excludeuser']))
181 - $this->dieUsage('user and excludeuser cannot be used together', 'user-excludeuser');
182 - if(!is_null($params['user']))
183 - $this->addWhereFld('rc_user_text', $params['user']);
184 - if(!is_null($params['excludeuser']))
185 - $this->addWhere('rc_user_text != ' . $this->getDB()->addQuotes($params['excludeuser']));
186 - }
 177+ if(!is_null($params['user']) && !is_null($params['excludeuser']))
 178+ $this->dieUsage('user and excludeuser cannot be used together', 'user-excludeuser');
 179+ if(!is_null($params['user']))
 180+ $this->addWhereFld('rc_user_text', $params['user']);
 181+ if(!is_null($params['excludeuser']))
 182+ $this->addWhere('rc_user_text != ' . $this->getDB()->addQuotes($params['excludeuser']));
187183
188184
189185 # This is an index optimization for mysql, as done in the Special:Watchlist page
@@ -336,6 +332,9 @@
337333 '!patrolled',
338334 )
339335 ),
 336+ 'owner' => array (
 337+ ApiBase :: PARAM_TYPE => 'user'
 338+ ),
340339 'token' => array (
341340 ApiBase :: PARAM_TYPE => 'string'
342341 )
@@ -357,6 +356,7 @@
358357 'Show only items that meet this criteria.',
359358 'For example, to see only minor edits done by logged-in users, set show=minor|!anon'
360359 ),
 360+ 'owner' => "The name of the user whose watchlist you'd like to access",
361361 'token' => "Give a security token (settable in preferences) to allow access to another user's watchlist"
362362 );
363363 }
@@ -371,7 +371,8 @@
372372 'api.php?action=query&list=watchlist&wlprop=ids|title|timestamp|user|comment',
373373 'api.php?action=query&list=watchlist&wlallrev&wlprop=ids|title|timestamp|user|comment',
374374 'api.php?action=query&generator=watchlist&prop=info',
375 - 'api.php?action=query&generator=watchlist&gwlallrev&prop=revisions&rvprop=timestamp|user'
 375+ 'api.php?action=query&generator=watchlist&gwlallrev&prop=revisions&rvprop=timestamp|user',
 376+ 'api.php?action=query&list=watchlist&wlowner=Bob_Smith&wltoken=d8d562e9725ea1512894cdab28e5ceebc7f20237'
376377 );
377378 }
378379
Index: trunk/phase3/includes/api/ApiFeedWatchlist.php
@@ -75,8 +75,8 @@
7676 'wllimit' => (50 > $wgFeedLimit) ? $wgFeedLimit : 50
7777 );
7878
79 - if (!is_null($params['wluser']))
80 - $fauxReqArr['wluser'] = $params['wluser'];
 79+ if (!is_null($params['wlowner']))
 80+ $fauxReqArr['wlowner'] = $params['wlowner'];
8181 if (!is_null($params['wltoken']))
8282 $fauxReqArr['wltoken'] = $params['wltoken'];
8383
@@ -158,7 +158,7 @@
159159 ApiBase :: PARAM_MAX => 72,
160160 ),
161161 'allrev' => null,
162 - 'wluser' => array (
 162+ 'wlowner' => array (
163163 ApiBase :: PARAM_TYPE => 'user'
164164 ),
165165 'wltoken' => array (
@@ -172,7 +172,7 @@
173173 'feedformat' => 'The format of the feed',
174174 'hours' => 'List pages modified within this many hours from now',
175175 'allrev' => 'Include multiple revisions of the same page within given timeframe.',
176 - 'wluser' => "The user whose watchlist you want (must be accompanied by wltoken if it's not you)",
 176+ 'wlowner' => "The user whose watchlist you want (must be accompanied by wltoken if it's not you)",
177177 'wltoken' => 'Security token that requested user set in their preferences'
178178 );
179179 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r53703Add opt-in RSS feed for watchlist...simetrical01:22, 24 July 2009

Comments

#Comment by Cat1205123 (talk | contribs)   02:54, 13 August 2009

I don't know if my voice counts for anything, but I'd like to see this implemented.

Status & tagging log