Merge "Don't break existing expiry time of "infinity" when modifying protection"
[lhc/web/wiklou.git] / includes / objectcache / ObjectCache.php
index 3be251c..633b34a 100644 (file)
@@ -27,7 +27,7 @@
  * @ingroup Cache
  */
 class ObjectCache {
-       static $instances = array();
+       public static $instances = array();
 
        /**
         * Get a cached instance of the specified type of cache object.
@@ -87,8 +87,9 @@ class ObjectCache {
                        $class = $params['class'];
                        return new $class( $params );
                } else {
-                       throw new MWException( "The definition of cache type \"" . print_r( $params, true ) . "\" lacks both " .
-                               "factory and class parameters." );
+                       throw new MWException( "The definition of cache type \""
+                               . print_r( $params, true ) . "\" lacks both "
+                               . "factory and class parameters." );
                }
        }
 
@@ -118,11 +119,15 @@ class ObjectCache {
        /**
         * Factory function referenced from DefaultSettings.php for CACHE_ACCEL.
         *
+        * This will look for any APC style server-local cache.
+        * A fallback cache can be specified if none is found.
+        *
         * @param array $params
+        * @param int|string $fallback Fallback cache, e.g. (CACHE_NONE, "hash") (since 1.24)
         * @throws MWException
         * @return BagOStuff
         */
-       static function newAccelerator( $params ) {
+       static function newAccelerator( $params, $fallback = null ) {
                if ( function_exists( 'apc_fetch' ) ) {
                        $id = 'apc';
                } elseif ( function_exists( 'xcache_get' ) && wfIniGetBool( 'xcache.var_size' ) ) {
@@ -130,6 +135,9 @@ class ObjectCache {
                } elseif ( function_exists( 'wincache_ucache_get' ) ) {
                        $id = 'wincache';
                } else {
+                       if ( $fallback ) {
+                               return self::newFromId( $fallback );
+                       }
                        throw new MWException( "CACHE_ACCEL requested but no suitable object " .
                                "cache is present. You may want to install APC." );
                }