global $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType;
$candidates = [ $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType ];
foreach ( $candidates as $candidate ) {
+ $cache = false;
if ( $candidate !== CACHE_NONE && $candidate !== CACHE_ANYTHING ) {
- return self::getInstance( $candidate );
+ $cache = self::getInstance( $candidate );
+ // CACHE_ACCEL might default to nothing if no APCu
+ // See includes/ServiceWiring.php
+ if ( !( $cache instanceof EmptyBagOStuff ) ) {
+ return $cache;
+ }
}
}
* @throws UnexpectedValueException
*/
public static function newWANCacheFromParams( array $params ) {
- $erGroup = MediaWikiServices::getInstance()->getEventRelayerGroup();
+ global $wgCommandLineMode;
+
+ $services = MediaWikiServices::getInstance();
+
+ $erGroup = $services->getEventRelayerGroup();
foreach ( $params['channels'] as $action => $channel ) {
$params['relayers'][$action] = $erGroup->getRelayer( $channel );
$params['channels'][$action] = $channel;
} else {
$params['logger'] = LoggerFactory::getInstance( 'objectcache' );
}
+ if ( !$wgCommandLineMode ) {
+ // 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'];
return new $class( $params );