Page MenuHomePhabricator

For pre-2005 users the API userinfo says the registration is the current day
Open, LowPublicBUG REPORT

Description

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

What happens?:

The field registrationdate is the current date and time (currently "registrationdate": "2024-03-24T16:46:27Z"), and it is updated when the query is refreshed.

What should have happened instead?:

Either the field registrationdate should be missing (given the date is not known) either it should be null (like the value in the database).

I find null would be a better choice to be coherent with other values (like api.php?action=query&list=users&usprop=registration like in T350741 -- example on ApiSandbox with my user).

This bug could disappear on individual wikis if/when some script like described in T24097 is run, but before such action is done a more realistic value should be written in this API request.

Software version (skip for WMF-hosted wikis like Wikipedia):

MediaWiki: rMW768fd92

Event Timeline

Seb35 triaged this task as Low priority.Mar 24 2024, 4:48 PM

The relevant code in includes/api/ApiQueryUserInfo.php function getCurrentUserInfo is:

if ( isset( $this->prop['registrationdate'] ) ) {
        $regDate = $user->getRegistration();
        if ( $regDate !== false ) {
                $vals['registrationdate'] = wfTimestamp( TS_ISO_8601, $regDate );
        }
}

How it returns the current day:

  1. User::getRegistration() returns string|false|null (string = timestamp, false = anonymous user, null = logged-in user but no data),
  2. Here $regDate = null,
  3. so the condition $regDate !== false is true (because null !== false),
  4. and finally wfTimestamp( TS_ISO_8601, null ) returns the current date.

Change #1013715 had a related patch set uploaded (by Seb35; author: Seb35):

[mediawiki/core@master] api: In QueryUserInfo, return null as registrationdate for pre-2005 users

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