Page MenuHomePhabricator

Update AbuseFilter to use UserIdentityUtils instead of UserNameUtils
Closed, ResolvedPublic2 Estimated Story Points

Description

UserIdentityUtils was recently added, and should be used instead of UserNameUtils to check for temporary/named users in some circumstances, because it has fewer dependencies.

We recently added such checks to AbuseFilter. This task is to see whether any of these calls can be made using UserIdentityUtils, and to update them if so.

When to prefer UserIdentityUtils:

  • A UserIdentity is available, but not a User/Authority
  • The class in question does not already depend on UserNameUtils
  • It's necessary to check ::isNamed (which exists on UserIdentityUtils but not UserNameUtils)

When to prefer UserNameUtils:

  • Only the username is available
  • UserNameUtils is already a dependency of the class

Note that UserNameUtils::isTemp takes a string, whereas UserIdentityUtils::isTemp takes a UserIdentity.

Please see the relevant methods on both classes for more details.

Event Timeline

AGueyte set the point value for this task to 1.Jul 26 2023, 2:11 PM
AGueyte changed the point value for this task from 1 to 2.Jul 26 2023, 3:21 PM

Change 941943 had a related patch set uploaded (by AGueyte; author: AGueyte):

[mediawiki/extensions/AbuseFilter@master] Replace userNameUtils with UserIdentityUtils

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

Change 941943 merged by jenkins-bot:

[mediawiki/extensions/AbuseFilter@master] Replace userNameUtils with UserIdentityUtils

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

@AGueyte Temp user can access AbuseFilter and go to the edit section of any of the abuse filters but cannot edit. The task will move to Done. Thanks for all your work!

Environment: Local
Mediawiki: 1.41.0-alpha (c371f2e) 18:36, 8 August 2023
AbuseFilter: (13ea7ab) 07:00, 8 August 2023

T342741_AbuseFilter_TempAccess1.png (713×3 px, 259 KB)

T342741_AbuseFilter_TempAccess2.png (1×3 px, 308 KB)