Page MenuHomePhabricator

Factor user registration loading to LocalUserRegistrationProvider
Closed, ResolvedPublic

Description

As part of T344694: [IP Masking] Alert temporary accounts 10 days before expiration, UserRegistrationLookup and LocalUserRegistrationProvider classes were added into MediaWiki Core (in order to allow for multiple registration sources). However, the main registration lookup still happens in the mega User object. In this task, we should:

  • Move registration loading to LocalUserRegistrationProvider and soft-deprecate User::getRegistration
  • Replace usages of User::getRegistration
  • Hard-deprecate User::getRegistration in favour of UserRegistrationLookup
  • (Eventually) remove User::getRegistration

Event Timeline

Change 998599 had a related patch set uploaded (by Zabe; author: Zabe):

[mediawiki/core@master] Factor user registration loading to LocalUserRegistrationProvider

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

Hi @Zabe! Thanks so much for starting the work for this! Are you interested in finishing the patch to pass CI? Is there something I can do (or my team can do) to help you with moving this forward?

Hey, I got the patch to pass CI now. But I need to say that I have currently no testing setup around. So I would be more than happy if you could review the patch and also roughly test it if thats feasible. Thanks! :)

mszwarc subscribed.

I'm adding this task to our sprint, as we will need getRegistration to be extracted from User in order to proceed with T406544: Create a way to technically enforce policies for restricted groups. It's not immediately needed, but I'll probably look at the proposed patch in the next week, unless it's updated earlier.

Change #998599 merged by jenkins-bot:

[mediawiki/core@master] Factor user registration loading to LocalUserRegistrationProvider

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

Change #1199707 had a related patch set uploaded (by Mszwarc; author: Mszwarc):

[mediawiki/extensions/GrowthExperiments@master] Update tests to prepare for dropping mRegistration from User

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

Change #1199710 had a related patch set uploaded (by Mszwarc; author: Mszwarc):

[mediawiki/core@master] Drop mRegistration from User

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

Change #1199711 had a related patch set uploaded (by Mszwarc; author: Mszwarc):

[mediawiki/extensions/GrowthExperiments@master] CreateMenteeHelpers: Don't recreate the user to refresh registration

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

Change #1199707 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] Update tests to prepare for dropping mRegistration from User

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

Change #1199710 merged by jenkins-bot:

[mediawiki/core@master] Drop mRegistration from User

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

Change #1199711 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] CreateMenteeHelpers: Don't recreate the user to refresh registration

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

Change #1202633 had a related patch set uploaded (by Mszwarc; author: Mszwarc):

[mediawiki/core@master] User: Update cache version

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

Change #1202633 merged by jenkins-bot:

[mediawiki/core@master] User: Update cache version

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

Moving back to Ready to reflect that there are no more patches to review at the moment

I went through usages of User::getRegistration() in the WMF-deployed code and I think it's the most important to update the files listed below. They create a full User object only in order to get its registration date. We no longer need to do that.

AbuseFilter:

CheckUser:

GrowthExperiments:

@mszwarc Do you plan to upload the code to do this, or should I tackle the Growth-facing parts on our side?

@mszwarc Do you plan to upload the code to do this, or should I tackle the Growth-facing parts on our side?

Yes, I'll prepare the code, probably tomorrow

Okay, feel free to ask me for review on that if needed! Thanks for your work on this.

Change #1204802 had a related patch set uploaded (by Mszwarc; author: Mszwarc):

[mediawiki/extensions/GrowthExperiments@master] Use UserRegistrationLookup to get regitration dates

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

Change #1204805 had a related patch set uploaded (by Mszwarc; author: Mszwarc):

[mediawiki/extensions/AbuseFilter@master] Use UserRegistrationLookup to get registration dates

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

Change #1204819 had a related patch set uploaded (by Mszwarc; author: Mszwarc):

[mediawiki/extensions/CheckUser@master] Use UserRegistrationLookup to get registration date

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

Change #1204805 merged by jenkins-bot:

[mediawiki/extensions/AbuseFilter@master] Use UserRegistrationLookup to get registration dates

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

Change #1204819 merged by jenkins-bot:

[mediawiki/extensions/CheckUser@master] Use UserRegistrationLookup to get registration date

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

Change #1204987 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/core@master] User: Update class doc to explain UserRegistrationLookup

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

Change #1204802 merged by jenkins-bot:

[mediawiki/extensions/GrowthExperiments@master] Use UserRegistrationLookup to get registration dates

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

mszwarc added a project: patch-welcome.

There are still a few usages of User::getRegistration() in the production code. However, as it less and less related to the actual projects the PSI team is working on, I'll unassign myself from this task and stop here. To reflect that, I'm moving this task to the Done column on our sprint board.

Most of the remaining code can be updated by injecting UserRegistrationLookup to the relevant class and then update $user->getRegistration() to $this->userRegistrationLookup->getRegistration( $user ).

It's seems simple enough that I'm tagging it with patch-welcome and I can provide reviews in case the patches arrive.

Change #1204987 merged by jenkins-bot:

[mediawiki/core@master] User: Update class doc to explain UserRegistrationLookup

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

Niharika claimed this task.