Page MenuHomePhabricator

GenderCache needs UserNameUtils but that gives a circular dependency / Split MediaWikiTitleCodec into TitleParser and TitleFormatter for proper dependencies?
Closed, ResolvedPublic

Description

The GenderCache class is a service and calling the deprecated User::isValidUserName. The replacement is the UserNameUtils service.

But the UserNameUtils indirectly used the GenderCache and than a circular dependency is given and exception thrown.
The way is: UserNameUtils -> TitleParser -> _MediaWikiTitleCodec -> GenderCache -> UserNameUtils

From my understanding of the code, the GenderCache in class MediaWikiTitleCodec is only used for the TitleFormatter part (Used in getNamespaceName) and UserNameUtils needs only a TitleParser.
So MediaWikiTitleCodec needs a split or how to resolve this situation?
Creating own MediaWikiTitleCodec as TitleParser for the UserNameUtils without GenderCache because the function should not be called?

Event Timeline

I think the User::isValidUserName() call can just be removed. The worst thing that can happen is that the DB will have to search for nonexistent rows. If that's a performance problem, the check can be moved to the caller of GenderCache. But some callers (e.g. ApiPageSet) are getting the inputs from an already validated source.

Change 689533 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/core@master] GenderCache: remove checking for valid usernames

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

I think the User::isValidUserName() call can just be removed. The worst thing that can happen is that the DB will have to search for nonexistent rows. If that's a performance problem, the check can be moved to the caller of GenderCache. But some callers (e.g. ApiPageSet) are getting the inputs from an already validated source.

Makes sense to me (we already can be searching for nonexistent rows since we don't verify that the username corresponds to a user that exists, just one that could exist) - sent a patch to remove the call entirely

Change 689533 merged by jenkins-bot:

[mediawiki/core@master] GenderCache: remove checking for valid usernames

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

DannyS712 claimed this task.