* Fixed fatal for bad wlowner usernames

* Use the relevant user object to check patrol abilities rather than always using $wgUser
This commit is contained in:
Aaron Schulz 2009-10-17 04:18:49 +00:00
parent 7297529d7b
commit 60660e2af3

View file

@ -59,7 +59,10 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
$params = $this->extractRequestParams();
if (!is_null($params['owner']) && !is_null($params['token'])) {
$user = User::newFromName($params['owner']);
$user = User::newFromName($params['owner'],false);
if( !$user->getId() ) {
$this->dieUsage( 'Specified user does not exist' );
}
$token = $user->getOption('watchlisttoken');
if ($token == '' || $token != $params['token']) {
$this->dieUsage('Incorrect watchlist token provided -- please set a correct token in Special:Preferences', 'bad_wltoken');
@ -84,8 +87,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
$this->fld_patrol = isset($prop['patrol']);
if ($this->fld_patrol) {
global $wgUser;
if (!$wgUser->useRCPatrol() && !$wgUser->useNPPatrol())
if (!$user->useRCPatrol() && !$user->useNPPatrol())
$this->dieUsage('patrol property is not available', 'patrol');
}
}