GenderCache: remove checking for valid usernames

Violates proper DI by retrieving UserNameUtils from
MediaWikiServices instead of injecting, but can't inject
because that creates a circular dependency (UsernameUtils
indirectly relies on GenderCache via MediaWikiTitleCodec).

If callers can validate that they are only searching for the
genders of valid user names, that would be great but its
not required, at worst we just search for a few
extra database rows that don't exist.

Bug: T267054
Change-Id: I00813228e177a7a7d13969fae85cf725def8f879
This commit is contained in:
DannyS712 2021-05-12 06:36:31 +00:00
parent 675694308c
commit ba2e216399

View file

@ -150,7 +150,6 @@ class GenderCache {
*/
public function doQuery( $users, $caller = '' ) {
$default = $this->getDefault();
$userNameUtils = MediaWikiServices::getInstance()->getUserNameUtils();
$usersToCheck = [];
foreach ( (array)$users as $value ) {
@ -159,10 +158,8 @@ class GenderCache {
if ( !isset( $this->cache[$name] ) ) {
// For existing users, this value will be overwritten by the correct value
$this->cache[$name] = $default;
// query only for valid names, which can be in the database
if ( $userNameUtils->isValid( $name ) ) {
$usersToCheck[] = $name;
}
// We no longer verify that only valid names are checked for, T267054
$usersToCheck[] = $name;
}
}