Page MenuHomePhabricator

ParamValidator rejects temporary usernames where the local account does not exist
Closed, ResolvedPublic1 Estimated Story PointsBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

Compare:

What happens?:

The API returns a "baduser" error.

What should have happened instead?:

The API should provide global user info, just as it does on the Special:CentralAuth page.

Other information (browser name/version, screenshots, etc.):

I used Meta as an example, which after T376132 will accept temp account names, but I assume this bug will persist anywhere temp accounts aren't enabled.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

I used Meta as an example, which after T376132 will accept temp account names

Apparently that didn't make a difference.

Apparently a core bug:

tgr@mwmaint2002:~$ mwscript shell.php metawiki
> $am = new ApiMain()
> $pv = new MediaWiki\Api\Validator\ApiParamValidator( $am, MW::srv()->getObjectFactory())
> use MediaWiki\ParamValidator\TypeDef\UserDef;
> use Wikimedia\ParamValidator\ParamValidator;
> $pv->validateValue( $am, 'user', '~2024-7820', [ ParamValidator::PARAM_TYPE => 'user', UserDef::PARAM_ALLOWED_USER_TYPES => [ 'name', 'temp', 'interwiki' ] ] )

   MediaWiki\Api\ApiUsageException  Invalid value "~2024-7820" for user parameter "user".

> sudo $userdef = $pv->paramValidator->getTypeDef('user')
> sudo $userdef->processUser( '~2024-7820' )
= [
    "temp",
    null,
  ]
Tgr renamed this task from CentralAuth API rejects temporary usernames on wikis with temporary accounts disabled to ParamValidator rejects temporary usernames on wikis with temporary accounts disabled.Oct 25 2024, 10:28 AM
Tgr renamed this task from ParamValidator rejects temporary usernames on wikis with temporary accounts disabled to ParamValidator rejects temporary usernames on wikis with temporary accounts disabled but known.Oct 25 2024, 10:30 AM

I used Meta as an example, which after T376132 will accept temp account names

Apparently that didn't make a difference.

In fact, the error only occurs on Meta.
https://en.wikipedia.org/w/api.php?action=query&meta=globaluserinfo&guiuser=~2024-7820

tgr@mwmaint2002:~$ mwscript shell.php enwiki
...
> $pv->validateValue( $am, 'user', '~2024-7820', [ ParamValidator::PARAM_TYPE => 'user', UserDef::PARAM_ALLOWED_USER_TYPES => [ 'name', 'temp', 'interwiki' ] ] )
= "~2024-7820"

Introduced in rMWe66805c27422: Add temporary user type to UserDef I think. UserIdentityLookup::getUserIdentityByName() somewhat confusingly returns null if the user name is valid but the user does not exist locally.

Tgr renamed this task from ParamValidator rejects temporary usernames on wikis with temporary accounts disabled but known to ParamValidator rejects temporary usernames where the local account does not exist.Oct 25 2024, 10:41 AM

Change #1085356 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):

[mediawiki/core@master] Allow UserDef 'temp' type to accept non-existing temp usernames

https://gerrit.wikimedia.org/r/1085356

Dreamy_Jazz changed the point value for this task from 2 to 1.Thu, Oct 31, 11:33 AM

Change #1085356 merged by jenkins-bot:

[mediawiki/core@master] Allow UserDef 'temp' type to accept non-existing temp usernames

https://gerrit.wikimedia.org/r/1085356

I used the API to globally block a temp and named user which did not exist on the local wiki.

I also looked up the same users on meta=globaluserinfo.

Test environment: https://meta.wikimedia.beta.wmflabs.org MediaWiki 1.44.0-alpha (f0dfd5e) 07:04, 1 November 2024.