Page MenuHomePhabricator

Clean up $performer parameter of AuthManager::autoCreateUser()
Closed, ResolvedPublic

Description

Currently on self-autocreation, some callers pass in the user as the performer and some pass in null. That's confusing and increases the likelihood of bugs. We should probably just deprecate null as a valid value. (It's also used by maintenance scripts but those could just pass something like new UltimateAuthority( User::newSystemUser( User::MAINTENANCE_SCRIPT_USER, [ 'steal' => true ] ).)

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
DAlangi_WMF changed the task status from Open to In Progress.Nov 4 2025, 11:56 AM
DAlangi_WMF claimed this task.

Change #1201589 had a related patch set uploaded (by D3r1ck01; author: Derick Alangi):

[mediawiki/extensions/CentralAuth@master] Emit deprecation warnings when NULL is used as the performer

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

Change #1201590 had a related patch set uploaded (by D3r1ck01; author: Derick Alangi):

[mediawiki/core@master] auth: Minor fixes to the AuthManager::autoCreateUser() docs

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

Change #1201604 had a related patch set uploaded (by D3r1ck01; author: Derick Alangi):

[mediawiki/extensions/CheckUser@master] maintenance: Avoid NULL as performer to AuthManager::autoCreateUser()

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

Change #1201605 had a related patch set uploaded (by D3r1ck01; author: Derick Alangi):

[mediawiki/extensions/Flow@master] Dump: Fix passing NULL to ::autoCreateUser()

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

Change #1201590 merged by jenkins-bot:

[mediawiki/core@master] auth: Minor fixes to the AuthManager::autoCreateUser() docs

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

Change #1201605 abandoned by D3r1ck01:

[mediawiki/extensions/Flow@master] Dump: Fix passing NULL to ::autoCreateUser()

Reason:

With the latest PS at I16497e4789d38d1ade07aceeebb4031359bd4b8c, this patch is no longer needed.

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

Change #1201681 had a related patch set uploaded (by D3r1ck01; author: Derick Alangi):

[mediawiki/core@master] auth: Deprecate passing NULL as performer to autoCreateUser()

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

Change #1201604 merged by jenkins-bot:

[mediawiki/extensions/CheckUser@master] maintenance: Avoid NULL as performer to AuthManager::autoCreateUser()

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

Change #1201605 restored by D3r1ck01:

[mediawiki/extensions/Flow@master] Dump: Fix passing NULL to ::autoCreateUser()

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

It's not actually clear to me what we should pass as performer instead of null. The code of AuthManager::autoCreateUser() itself mostly uses an anonymous user as performer when null is given. Some of the patches proposed here pass the user to be created instead, which may be an unintended change in behavior. @Tgr Any advice?

There are three options:

  • the operation shouldn't fail: use an UltimateAuthority
  • the operation should fail if there's a conflicting AbuseFilter etc, regardless of who the user is: use an anonymous user object
  • the operation should fail if there's a conflicting AbuseFilter etc, unless the (central) user has permissions to override it: use $user

I think most of the time the third makes most sense, even if it's a behavior change.

We could also go the opposite direction, keep null as the "user is same as performer" value, and change the internal logic so it uses $user rather than a new anonymous user in that case. Either way, we should avoid the situation where callers sometimes pass null and sometimes the user, with the difference between the two being non-obvious.

Change #1201605 merged by jenkins-bot:

[mediawiki/extensions/Flow@master] Dump: Fix passing NULL to ::autoCreateUser()

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

Change #1201589 merged by jenkins-bot:

[mediawiki/extensions/CentralAuth@master] Use the `$user` object when performer is passed in as NULL

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

Change #1201681 merged by jenkins-bot:

[mediawiki/core@master] auth: Use the user object when action performer is NULL

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

Thanks for landing the final piece @matmarex. This can be resolved now!