Page MenuHomePhabricator

GenderCache::getGenderOf uses $wgUser
Closed, ResolvedPublic

Description

Use should be removed

Event Timeline

DannyS712 triaged this task as Medium priority.Jun 8 2020, 1:58 AM
DannyS712 created this task.
DannyS712 moved this task from Unsorted to In progress on the User-DannyS712 board.

Change 603072 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/core@master] Add GenderCache::getUserGender to replace ::getGenderOf

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

Change 603072 abandoned by DannyS712:
Add GenderCache::getUserGender to replace ::getGenderOf

Reason:
callers don't all have a user available, including their callers

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

Change 603074 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/core@master] GenderCache::getGenderOf - remove use of global $wgUser

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

$wgUser is used to avoid a cache miss for the current user and return the value from the user object instead.

It could also be possible to inject/call that ealier into the cache to avoid that it is requested the first time after the cache is full.
But that would mean the cache is created on each request, which seems not a good idea

Have no idea how to avoid the request context at all here.

Change 603074 merged by jenkins-bot:
[mediawiki/core@master] GenderCache::getGenderOf - remove use of global $wgUser

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