From: Aaron Schulz Date: Sat, 17 Oct 2009 04:18:49 +0000 (+0000) Subject: * Fixed fatal for bad wlowner usernames X-Git-Tag: 1.31.0-rc.0~39253 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=60660e2af3eab2a8afcdc5a02e385b75ccc180f9;p=lhc%2Fweb%2Fwiklou.git * Fixed fatal for bad wlowner usernames * Use the relevant user object to check patrol abilities rather than always using $wgUser --- 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'); } }