aboutsummaryrefslogtreecommitdiffstats
path: root/includes/objectcache/ObjectCache.php
diff options
context:
space:
mode:
authorTimo Tijhof <krinkle@fastmail.com>2023-02-14 21:06:17 +0000
committerKrinkle <krinkle@fastmail.com>2023-02-15 00:21:37 +0000
commitae944fc38b169b4dcde3cd14341a17d21f463116 (patch)
tree19ae5d39208355425d8ece0759e22862e7a23de5 /includes/objectcache/ObjectCache.php
parent83301c36bbd21b31afe73d23fa4196c084d8728b (diff)
downloadmediawikicore-ae944fc38b169b4dcde3cd14341a17d21f463116.tar.gz
mediawikicore-ae944fc38b169b4dcde3cd14341a17d21f463116.zip
ObjectCache: Make newFromParams() more suitable for internal re-use
I added the `Config` parameter not so long ago, but this still seems awkward and insufficient. Instead of requiring the caller in ServiceWiring to unpack each service, do this here instead to better separate the concerns between what a service owner should know vs what maintainers of ObjectCache need to know. Document the parameter as internal going forward. There exist no callers Codesearch Everywhere outside these two core files. Bug: T329680 Change-Id: I37e3fcae0551ba96d480071b2da5166ac966092e
Diffstat (limited to 'includes/objectcache/ObjectCache.php')
-rw-r--r--includes/objectcache/ObjectCache.php11
1 files changed, 6 insertions, 5 deletions
diff --git a/includes/objectcache/ObjectCache.php b/includes/objectcache/ObjectCache.php
index 152e3c190f98..b9beeb54f959 100644
--- a/includes/objectcache/ObjectCache.php
+++ b/includes/objectcache/ObjectCache.php
@@ -133,11 +133,13 @@ class ObjectCache {
* - class: BagOStuff subclass constructed with $params.
* - loggroup: Alias to set 'logger' key with LoggerFactory group.
* - .. Other parameters passed to factory or class.
- * @param Config|null $conf (Since 1.35)
+ * @param MediaWikiServices|null $services [internal]
* @return BagOStuff
*/
- public static function newFromParams( array $params, Config $conf = null ) {
- $services = MediaWikiServices::getInstance();
+ public static function newFromParams( array $params, MediaWikiServices $services = null ) {
+ $services ??= MediaWikiServices::getInstance();
+ $conf = $services->getMainConfig();
+
// Apply default parameters and resolve the logger instance
$params += [
'logger' => LoggerFactory::getInstance( $params['loggroup'] ?? 'objectcache' ),
@@ -160,7 +162,6 @@ class ObjectCache {
}
$class = $params['class'];
- $conf ??= $services->getMainConfig();
// Normalization and DI for SqlBagOStuff
if ( is_a( $class, SqlBagOStuff::class, true ) ) {
@@ -211,7 +212,7 @@ class ObjectCache {
foreach ( $params['caches'] ?? [] as $i => $cacheInfo ) {
// Ensure logger, keyspace, asyncHandler, etc are injected just as if
// one of these was configured without MultiWriteBagOStuff.
- $params['caches'][$i] = self::newFromParams( $cacheInfo, $conf );
+ $params['caches'][$i] = self::newFromParams( $cacheInfo, $services );
}
}