Merge "SpecialPages: Add ul { margin-top: 0; margin-bottom: 0 } for multicolumn"
[lhc/web/wiklou.git] / includes / objectcache / ObjectCache.php
index cf9033b..67d2346 100644 (file)
@@ -246,8 +246,14 @@ class ObjectCache {
                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;
+                               }
                        }
                }
 
@@ -326,7 +332,11 @@ class ObjectCache {
         * @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;
@@ -337,6 +347,12 @@ class ObjectCache {
                } 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 );