X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fobjectcache%2FObjectCache.php;h=6d76d5ed1207739a933e7d7d89789a4e22ba53f1;hb=4aa6454d454df807059db5e794ef620896ff2e3d;hp=a6f55e602613e7ef414c623b0c43717914821312;hpb=3a77f5d74a6899c1f9fda78b5a2569f9f722ac3a;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/objectcache/ObjectCache.php b/includes/objectcache/ObjectCache.php index a6f55e6026..6d76d5ed12 100644 --- a/includes/objectcache/ObjectCache.php +++ b/includes/objectcache/ObjectCache.php @@ -182,13 +182,9 @@ class ObjectCache { } elseif ( isset( $params['class'] ) ) { $class = $params['class']; // Automatically set the 'async' update handler - $params['asyncHandler'] = isset( $params['asyncHandler'] ) - ? $params['asyncHandler'] - : 'DeferredUpdates::addCallableUpdate'; + $params['asyncHandler'] = $params['asyncHandler'] ?? 'DeferredUpdates::addCallableUpdate'; // Enable reportDupes by default - $params['reportDupes'] = isset( $params['reportDupes'] ) - ? $params['reportDupes'] - : true; + $params['reportDupes'] = $params['reportDupes'] ?? true; // Do b/c logic for SqlBagOStuff if ( is_a( $class, SqlBagOStuff::class, true ) ) { if ( isset( $params['server'] ) && !isset( $params['servers'] ) ) { @@ -289,7 +285,7 @@ class ObjectCache { $cache = MediaWikiServices::getInstance()->getLocalServerObjectCache(); if ( $cache instanceof EmptyBagOStuff ) { if ( is_array( $fallback ) ) { - $fallback = isset( $fallback['fallback'] ) ? $fallback['fallback'] : CACHE_NONE; + $fallback = $fallback['fallback'] ?? CACHE_NONE; } $cache = self::getInstance( $fallback ); } @@ -413,4 +409,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; + } }