Merge "Convert Special:DeletedContributions to use OOUI."
[lhc/web/wiklou.git] / includes / objectcache / ObjectCache.php
index 0f18479..0a4f0ed 100644 (file)
@@ -50,7 +50,7 @@ use MediaWiki\MediaWikiServices;
  *
  * - ObjectCache::getLocalServerInstance( $fallbackType )
  *   Purpose: Memory cache for very hot keys.
- *   Stored only on the individual web server (typically APC for web requests,
+ *   Stored only on the individual web server (typically APC or APCu for web requests,
  *   and EmptyBagOStuff in CLI mode).
  *   Not replicated to the other servers.
  *
@@ -190,7 +190,7 @@ class ObjectCache {
                                ? $params['reportDupes']
                                : true;
                        // Do b/c logic for SqlBagOStuff
-                       if ( is_subclass_of( $class, SqlBagOStuff::class ) ) {
+                       if ( is_a( $class, SqlBagOStuff::class, true ) ) {
                                if ( isset( $params['server'] ) && !isset( $params['servers'] ) ) {
                                        $params['servers'] = [ $params['server'] ];
                                        unset( $params['server'] );
@@ -265,7 +265,7 @@ class ObjectCache {
        /**
         * Factory function for CACHE_ACCEL (referenced from DefaultSettings.php)
         *
-        * This will look for any APC style server-local cache.
+        * This will look for any APC or APCu style server-local cache.
         * A fallback cache can be specified if none is found.
         *
         *     // Direct calls
@@ -274,36 +274,21 @@ class ObjectCache {
         *     // From $wgObjectCaches via newFromParams()
         *     ObjectCache::getLocalServerInstance( [ 'fallback' => $fallbackType ] );
         *
-        * @param int|string $fallback Fallback cache ID
+        * @param int|string|array $fallback Fallback cache or parameter map with 'fallback'
         * @return BagOStuff
         * @throws InvalidArgumentException
         * @since 1.27
-        * @deprecated Since 1.28; use MediaWikiServices::getLocalServerObjectCache
         */
        public static function getLocalServerInstance( $fallback = CACHE_NONE ) {
                $cache = MediaWikiServices::getInstance()->getLocalServerObjectCache();
-
-               return ( $cache instanceof EmptyBagOStuff )
-                       ? self::getInstance( $fallback )
-                       : $cache;
-       }
-
-       /**
-        * @param array $params [optional] Array key 'fallback' for $fallback.
-        * @param int|string $fallback Fallback cache, e.g. (CACHE_NONE, "hash") (since 1.24)
-        * @return BagOStuff
-        * @deprecated since 1.27
-        */
-       public static function newAccelerator( $params = [], $fallback = null ) {
-               if ( $fallback === null ) {
-                       if ( is_array( $params ) && isset( $params['fallback'] ) ) {
-                               $fallback = $params['fallback'];
-                       } elseif ( !is_array( $params ) ) {
-                               $fallback = $params;
+               if ( $cache instanceof EmptyBagOStuff ) {
+                       if ( is_array( $fallback ) ) {
+                               $fallback = isset( $fallback['fallback'] ) ? $fallback['fallback'] : CACHE_NONE;
                        }
+                       $cache = self::getInstance( $fallback );
                }
 
-               return self::getLocalServerInstance( $fallback );
+               return $cache;
        }
 
        /**
@@ -341,9 +326,9 @@ class ObjectCache {
         * @throws UnexpectedValueException
         */
        public static function newWANCacheFromParams( array $params ) {
+               $erGroup = MediaWikiServices::getInstance()->getEventRelayerGroup();
                foreach ( $params['channels'] as $action => $channel ) {
-                       $params['relayers'][$action] = MediaWikiServices::getInstance()->getEventRelayerGroup()
-                               ->getRelayer( $channel );
+                       $params['relayers'][$action] = $erGroup->getRelayer( $channel );
                        $params['channels'][$action] = $channel;
                }
                $params['cache'] = self::newFromParams( $params['store'] );