Merge "resourceloader: Make various CSSMin performance optimizations and cleanups"
[lhc/web/wiklou.git] / includes / objectcache / ObjectCache.php
index 67d2346..c384032 100644 (file)
@@ -337,9 +337,11 @@ class ObjectCache {
                $services = MediaWikiServices::getInstance();
 
                $erGroup = $services->getEventRelayerGroup();
-               foreach ( $params['channels'] as $action => $channel ) {
-                       $params['relayers'][$action] = $erGroup->getRelayer( $channel );
-                       $params['channels'][$action] = $channel;
+               if ( isset( $params['channels'] ) ) {
+                       foreach ( $params['channels'] as $action => $channel ) {
+                               $params['relayers'][$action] = $erGroup->getRelayer( $channel );
+                               $params['channels'][$action] = $channel;
+                       }
                }
                $params['cache'] = self::newFromParams( $params['store'] );
                if ( isset( $params['loggroup'] ) ) {
@@ -411,4 +413,21 @@ class ObjectCache {
                self::$instances = [];
                self::$wanInstances = [];
        }
+
+       /**
+        * Detects which local server cache library is present and returns a configuration for it
+        * @since 1.32
+        *
+        * @return int|string Index to cache in $wgObjectCaches
+        */
+       public static function detectLocalServerCache() {
+               if ( function_exists( 'apc_fetch' ) ) {
+                       return 'apc';
+               } elseif ( function_exists( 'apcu_fetch' ) ) {
+                       return 'apcu';
+               } elseif ( function_exists( 'wincache_ucache_get' ) ) {
+                       return 'wincache';
+               }
+               return CACHE_NONE;
+       }
 }