Page MenuHomePhabricator

ObjectCache::getLocalClusterInstance() is difficult to use with dependency injection
Closed, DuplicatePublic

Description

Problem
The local cluster object cache is not available in the service container. (The local server one is, as LocalServerObjectCache.) Services which need the local cluster object cache therefore rely on MediaWiki global state in their service wiring (and, by extension, on the default service container, since ObjectCache::newFromParams() gets several services from it) – a dependency that can’t be mocked away.

Proposed Solution
Add a service for the local cluster object cache to the service container. ObjectCache::getLocalClusterInstance() should probably be changed to match ObjectCache::getLocalServerInstance() – get the cache from the MediaWikiServices, possibly with a fallback type argument.