Page MenuHomePhabricator

Convert UserCache to a service with dependency injection
Closed, ResolvedPublic

Description

Currently, UserCache is retrieved through UserCache::singleton, and the actual constructor is protected. Within the class, it uses a debugger (currently via wfDebug), a load balancer (currently retrieves a database via wfGetDB) and a LinkBatch object.

I propose that this be converted to a service:

  • A \Psr\Log\LoggerInterface is injected
  • A Wikimedia\Rdbms\ILoadBalancer is injected
  • A MediaWiki\Cache\LinkBatchFactory is injected

The singleton method can be deprecated, and since the constructor isn't public there is no need for backwards compatibility with the current signature (no params at all). Codesearch reports that nothing currently extends the class

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Change 597150 had a related patch set uploaded (by DannyS712; owner: DannyS712):
[mediawiki/core@master] Convert UserCache to a service

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

Change 597150 merged by jenkins-bot:
[mediawiki/core@master] Convert UserCache to a service

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

Change 635574 had a related patch set uploaded (by Umherirrender; owner: Umherirrender):
[mediawiki/core@master] Inject UserCache into SpecialListFiles/SpecialNewFiles

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

Change 635574 merged by jenkins-bot:
[mediawiki/core@master] Inject UserCache into SpecialListFiles/SpecialNewFiles

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