* 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:
parent
7297529d7b
commit
60660e2af3
1 changed files with 5 additions and 3 deletions
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue