Remove getMainWANInstance and getMainStashInstance functions
[lhc/web/wiklou.git] / includes / objectcache / ObjectCache.php
index ffbc378..87edc8b 100644 (file)
@@ -119,7 +119,7 @@ class ObjectCache {
         * @return BagOStuff
         * @throws InvalidArgumentException
         */
-       public static function newFromId( $id ) {
+       private static function newFromId( $id ) {
                global $wgObjectCaches;
 
                if ( !isset( $wgObjectCaches[$id] ) ) {
@@ -146,7 +146,7 @@ class ObjectCache {
         *
         * @return string
         */
-       public static function getDefaultKeyspace() {
+       private static function getDefaultKeyspace() {
                global $wgCachePrefix;
 
                $keyspace = $wgCachePrefix;
@@ -178,7 +178,8 @@ class ObjectCache {
                } elseif ( isset( $params['class'] ) ) {
                        $class = $params['class'];
                        // Automatically set the 'async' update handler
-                       $params['asyncHandler'] = $params['asyncHandler'] ?? 'DeferredUpdates::addCallableUpdate';
+                       $params['asyncHandler'] = $params['asyncHandler']
+                               ?? [ DeferredUpdates::class, 'addCallableUpdate' ];
                        // Enable reportDupes by default
                        $params['reportDupes'] = $params['reportDupes'] ?? true;
                        // Do b/c logic for SqlBagOStuff
@@ -203,9 +204,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'];
                                }
@@ -296,7 +294,7 @@ class ObjectCache {
         * @return WANObjectCache
         * @throws UnexpectedValueException
         */
-       public static function newWANCacheFromId( $id ) {
+       private static function newWANCacheFromId( $id ) {
                global $wgWANObjectCaches, $wgObjectCaches;
 
                if ( !isset( $wgWANObjectCaches[$id] ) ) {
@@ -321,6 +319,7 @@ class ObjectCache {
         * @param array $params
         * @return WANObjectCache
         * @throws UnexpectedValueException
+        * @suppress PhanTypeMismatchReturn
         */
        public static function newWANCacheFromParams( array $params ) {
                global $wgCommandLineMode, $wgSecretKey;
@@ -352,30 +351,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.
         */
@@ -392,12 +367,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;
        }
 }