From 60660e2af3eab2a8afcdc5a02e385b75ccc180f9 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 17 Oct 2009 04:18:49 +0000 Subject: [PATCH] * Fixed fatal for bad wlowner usernames * Use the relevant user object to check patrol abilities rather than always using $wgUser --- includes/api/ApiQueryWatchlist.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/includes/api/ApiQueryWatchlist.php b/includes/api/ApiQueryWatchlist.php index 3c098211a6..6b42a79fa7 100644 --- a/includes/api/ApiQueryWatchlist.php +++ b/includes/api/ApiQueryWatchlist.php @@ -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'); } } -- 2.20.1