Don't initialize MediaWikiServices before extensions have been loaded
[lhc/web/wiklou.git] / includes / ServiceWiring.php
index f97d60d..ee92cbf 100644 (file)
@@ -404,24 +404,8 @@ return [
        },
 
        'LocalServerObjectCache' => function ( MediaWikiServices $services ) {
-               $mainConfig = $services->getMainConfig();
-
-               if ( function_exists( 'apc_fetch' ) ) {
-                       $id = 'apc';
-               } elseif ( function_exists( 'apcu_fetch' ) ) {
-                       $id = 'apcu';
-               } elseif ( function_exists( 'wincache_ucache_get' ) ) {
-                       $id = 'wincache';
-               } else {
-                       $id = CACHE_NONE;
-               }
-
-               if ( !isset( $mainConfig->get( 'ObjectCaches' )[$id] ) ) {
-                       throw new UnexpectedValueException(
-                               "Cache type \"$id\" is not present in \$wgObjectCaches." );
-               }
-
-               return \ObjectCache::newFromParams( $mainConfig->get( 'ObjectCaches' )[$id] );
+               $cacheId = \ObjectCache::detectLocalServerCache();
+               return \ObjectCache::newFromId( $cacheId );
        },
 
        'VirtualRESTServiceClient' => function ( MediaWikiServices $services ) {