objectcache: Deprecate ObjectCache::getWANInstance
[lhc/web/wiklou.git] / includes / objectcache / ObjectCache.php
index ad0f67e..73f3993 100644 (file)
@@ -43,11 +43,6 @@ use MediaWiki\MediaWikiServices;
  *
  * Primary entry points:
  *
- * - ObjectCache::getMainWANInstance()
- *   Purpose: Memory cache.
- *   Stored in the local data-center's main cache (keyspace different from local-cluster cache).
- *   Delete events are broadcasted to other DCs main cache. See WANObjectCache for details.
- *
  * - ObjectCache::getLocalServerInstance( $fallbackType )
  *   Purpose: Memory cache for very hot keys.
  *   Stored only on the individual web server (typically APC or APCu for web requests,
@@ -60,13 +55,6 @@ use MediaWiki\MediaWikiServices;
  *   Stored centrally within the local data-center. Not replicated to other DCs.
  *   Configured by $wgMainCacheType.
  *
- * - ObjectCache::getMainStashInstance()
- *   Purpose: Ephemeral global storage.
- *   Stored centrally within the primary data-center.
- *   Changes are applied there first and replicated to other DCs (best-effort).
- *   To retrieve the latest value (e.g. not from a replica DB), use BagOStuff::READ_LATEST.
- *   This store may be subject to LRU style evictions.
- *
  * - ObjectCache::getInstance( $cacheType )
  *   Purpose: Special cases (like tiered memory/disk caches).
  *   Get a specific cache type by key in $wgObjectCaches.
@@ -103,8 +91,10 @@ class ObjectCache {
         * @since 1.26
         * @param string $id A key in $wgWANObjectCaches.
         * @return WANObjectCache
+        * @deprecated since 1.34 Use MediaWikiServices::getMainWANObjectCache instead
         */
        public static function getWANInstance( $id ) {
+               wfDeprecated( __METHOD__, '1.34' );
                if ( !isset( self::$wanInstances[$id] ) ) {
                        self::$wanInstances[$id] = self::newWANCacheFromId( $id );
                }
@@ -204,9 +194,6 @@ class ObjectCache {
                                if ( !isset( $params['servers'] ) ) {
                                        $params['servers'] = $GLOBALS['wgMemCachedServers'];
                                }
-                               if ( !isset( $params['debug'] ) ) {
-                                       $params['debug'] = $GLOBALS['wgMemCachedDebug'];
-                               }
                                if ( !isset( $params['persistent'] ) ) {
                                        $params['persistent'] = $GLOBALS['wgMemCachedPersistent'];
                                }
@@ -322,8 +309,12 @@ class ObjectCache {
         * @param array $params
         * @return WANObjectCache
         * @throws UnexpectedValueException
+        * @suppress PhanTypeMismatchReturn
+        * @deprecated since 1.34 Use MediaWikiServices::getMainWANObjectCache
+        *  instead or use WANObjectCache::__construct directly
         */
        public static function newWANCacheFromParams( array $params ) {
+               wfDeprecated( __METHOD__, '1.34' );
                global $wgCommandLineMode, $wgSecretKey;
 
                $services = MediaWikiServices::getInstance();
@@ -353,30 +344,6 @@ class ObjectCache {
                return self::getInstance( $wgMainCacheType );
        }
 
-       /**
-        * Get the main WAN cache object.
-        *
-        * @since 1.26
-        * @return WANObjectCache
-        * @deprecated Since 1.28 Use MediaWikiServices::getInstance()->getMainWANObjectCache()
-        */
-       public static function getMainWANInstance() {
-               wfDeprecated( __METHOD__, '1.28' );
-               return MediaWikiServices::getInstance()->getMainWANObjectCache();
-       }
-
-       /**
-        * Get the cache object for the main stash.
-        *
-        * @return BagOStuff
-        * @since 1.26
-        * @deprecated Since 1.28 Use MediaWikiServices::getInstance()->getMainObjectStash()
-        */
-       public static function getMainStashInstance() {
-               wfDeprecated( __METHOD__, '1.28' );
-               return MediaWikiServices::getInstance()->getMainObjectStash();
-       }
-
        /**
         * Clear all the cached instances.
         */
@@ -393,12 +360,19 @@ class ObjectCache {
         */
        public static function detectLocalServerCache() {
                if ( function_exists( 'apcu_fetch' ) ) {
-                       return 'apcu';
+                       // Make sure the APCu methods actually store anything
+                       if ( PHP_SAPI !== 'cli' || ini_get( 'apc.enable_cli' ) ) {
+                               return 'apcu';
+                       }
                } elseif ( function_exists( 'apc_fetch' ) ) {
-                       return 'apc';
+                       // Make sure the APC methods actually store anything
+                       if ( PHP_SAPI !== 'cli' || ini_get( 'apc.enable_cli' ) ) {
+                               return 'apc';
+                       }
                } elseif ( function_exists( 'wincache_ucache_get' ) ) {
                        return 'wincache';
                }
+
                return CACHE_NONE;
        }
 }