From: Timo Tijhof Date: Tue, 8 Oct 2019 21:34:17 +0000 (+0100) Subject: objectcache: Log debug message for backend of WANObjectCache X-Git-Tag: 1.34.0-rc.0~12 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=377a5bd60d3854ab81df4c24bd3a3cdb18f4e241;ds=inline objectcache: Log debug message for backend of WANObjectCache While at it, disuse the static newWANCacheFromParams function which was only used by ServiceWiring (can now be deprecated, but done separate for easier backporting). Now that it is inlined, there is easy access to its logger. Bug: T234361 Change-Id: I118b6f01e49405984310030d44ee319bb25bfcdb (cherry picked from commit 3828558140eba4427d762937a2ea5ae352485d5f) --- diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php index 1ee17b2c61..6e31e864d9 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -372,14 +372,35 @@ return [ } $params = $mainConfig->get( 'WANObjectCaches' )[$id]; + + $logger = LoggerFactory::getInstance( $params['loggroup'] ?? 'objectcache' ); + $objectCacheId = $params['cacheId']; if ( !isset( $mainConfig->get( 'ObjectCaches' )[$objectCacheId] ) ) { throw new UnexpectedValueException( "Cache type \"$objectCacheId\" is not present in \$wgObjectCaches." ); } - $params['store'] = $mainConfig->get( 'ObjectCaches' )[$objectCacheId]; + $storeParams = $mainConfig->get( 'ObjectCaches' )[$objectCacheId]; + $store = ObjectCache::newFromParams( $storeParams ); + $logger->debug( 'MainWANObjectCache using store {class}', [ + 'class' => get_class( $store ) + ] ); + + $params['logger'] = $logger; + $params['cache'] = $store; + $params['secret'] = $params['secret'] ?? $mainConfig->get( 'SecretKey' ); + if ( !$mainConfig->get( 'CommandLineMode' ) ) { + // Send the statsd data post-send on HTTP requests; avoid in CLI mode (T181385) + $params['stats'] = $services->getStatsdDataFactory(); + // Let pre-emptive refreshes happen post-send on HTTP requests + $params['asyncHandler'] = [ DeferredUpdates::class, 'addCallableUpdate' ]; + } + + $class = $params['class']; + $instance = new $class( $params ); - return ObjectCache::newWANCacheFromParams( $params ); + '@phan-var WANObjectCache $instance'; + return $instance; }, 'MediaHandlerFactory' => function ( MediaWikiServices $services ) : MediaHandlerFactory {