Don't overload wluser parameter, use new wlowner
authorAryeh Gregor <simetrical@users.mediawiki.org>
Sun, 26 Jul 2009 17:04:22 +0000 (17:04 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Sun, 26 Jul 2009 17:04:22 +0000 (17:04 +0000)
Fix for r53703 based on code review by Roan.  Also improved error
message and sample documentation slightly.

includes/api/ApiFeedWatchlist.php
includes/api/ApiQueryWatchlist.php

index a26184c..4f2bb39 100644 (file)
@@ -75,8 +75,8 @@ class ApiFeedWatchlist extends ApiBase {
                                'wllimit' => (50 > $wgFeedLimit) ? $wgFeedLimit : 50
                        );
 
-                       if (!is_null($params['wluser']))
-                               $fauxReqArr['wluser'] = $params['wluser'];
+                       if (!is_null($params['wlowner']))
+                               $fauxReqArr['wlowner'] = $params['wlowner'];
                        if (!is_null($params['wltoken']))
                                $fauxReqArr['wltoken'] = $params['wltoken'];
 
@@ -158,7 +158,7 @@ class ApiFeedWatchlist extends ApiBase {
                                ApiBase :: PARAM_MAX => 72,
                        ),
                        'allrev' => null,
-                       'wluser' => array (
+                       'wlowner' => array (
                                ApiBase :: PARAM_TYPE => 'user'
                        ),
                        'wltoken' => array (
@@ -172,7 +172,7 @@ class ApiFeedWatchlist extends ApiBase {
                        'feedformat' => 'The format of the feed',
                        'hours'      => 'List pages modified within this many hours from now',
                        'allrev'     => 'Include multiple revisions of the same page within given timeframe.',
-                       'wluser'     => "The user whose watchlist you want (must be accompanied by wltoken if it's not you)",
+                       'wlowner'     => "The user whose watchlist you want (must be accompanied by wltoken if it's not you)",
                        'wltoken'    => 'Security token that requested user set in their preferences'
                );
        }
index 6d317aa..3c09821 100644 (file)
@@ -58,11 +58,11 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
 
                $params = $this->extractRequestParams();
 
-               if (!is_null($params['user']) && !is_null($params['token'])) {
-                       $user = User::newFromName($params['user']);
+               if (!is_null($params['owner']) && !is_null($params['token'])) {
+                       $user = User::newFromName($params['owner']);
                        $token = $user->getOption('watchlisttoken');
                        if ($token == '' || $token != $params['token']) {
-                               $this->dieUsage('Incorrect watchlist token provided', 'bad_wltoken');
+                               $this->dieUsage('Incorrect watchlist token provided -- please set a correct token in Special:Preferences', 'bad_wltoken');
                        }
                } elseif (!$wgUser->isLoggedIn()) {
                        $this->dieUsage('You must be logged-in to have a watchlist', 'notloggedin');
@@ -173,16 +173,12 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                        $this->addWhereIf('rc_patrolled != 0', isset($show['patrolled']));                      
                }
 
-               # Ignore extra user conditions if we're using token mode, since the
-               # user was already manually specified.
-               if(is_null($params['user']) || is_null($params['token'])) {
-                       if(!is_null($params['user']) && !is_null($params['excludeuser']))
-                               $this->dieUsage('user and excludeuser cannot be used together', 'user-excludeuser');
-                       if(!is_null($params['user']))
-                               $this->addWhereFld('rc_user_text', $params['user']);
-                       if(!is_null($params['excludeuser']))
-                               $this->addWhere('rc_user_text != ' . $this->getDB()->addQuotes($params['excludeuser']));
-               }
+               if(!is_null($params['user']) && !is_null($params['excludeuser']))
+                       $this->dieUsage('user and excludeuser cannot be used together', 'user-excludeuser');
+               if(!is_null($params['user']))
+                       $this->addWhereFld('rc_user_text', $params['user']);
+               if(!is_null($params['excludeuser']))
+                       $this->addWhere('rc_user_text != ' . $this->getDB()->addQuotes($params['excludeuser']));
 
 
                # This is an index optimization for mysql, as done in the Special:Watchlist page
@@ -336,6 +332,9 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                                        '!patrolled',
                                )
                        ),
+                       'owner' => array (
+                               ApiBase :: PARAM_TYPE => 'user'
+                       ),
                        'token' => array (
                                ApiBase :: PARAM_TYPE => 'string'
                        )
@@ -357,6 +356,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                                'Show only items that meet this criteria.',
                                'For example, to see only minor edits done by logged-in users, set show=minor|!anon'
                        ),
+                       'owner' => "The name of the user whose watchlist you'd like to access",
                        'token' => "Give a security token (settable in preferences) to allow access to another user's watchlist"
                );
        }
@@ -371,7 +371,8 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                        'api.php?action=query&list=watchlist&wlprop=ids|title|timestamp|user|comment',
                        'api.php?action=query&list=watchlist&wlallrev&wlprop=ids|title|timestamp|user|comment',
                        'api.php?action=query&generator=watchlist&prop=info',
-                       'api.php?action=query&generator=watchlist&gwlallrev&prop=revisions&rvprop=timestamp|user'
+                       'api.php?action=query&generator=watchlist&gwlallrev&prop=revisions&rvprop=timestamp|user',
+                       'api.php?action=query&list=watchlist&wlowner=Bob_Smith&wltoken=d8d562e9725ea1512894cdab28e5ceebc7f20237'
                );
        }