X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fobjectcache%2FObjectCache.php;h=abb88bac77112f7fb4c035836600df5ea87dc4e9;hb=b3acd4fb5d1263de5735c714a11f7a170777d1f1;hp=151bb065f997817c63eb27fb6027e58d32d8715c;hpb=a8131cac85f5cf08df4af9dfea9f25f16d3432c1;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/objectcache/ObjectCache.php b/includes/objectcache/ObjectCache.php index 151bb065f9..abb88bac77 100644 --- a/includes/objectcache/ObjectCache.php +++ b/includes/objectcache/ObjectCache.php @@ -137,19 +137,14 @@ class ObjectCache { * @return string */ public static function getDefaultKeyspace() { - global $wgCachePrefix, $wgDBname, $wgDBprefix; + global $wgCachePrefix; $keyspace = $wgCachePrefix; if ( is_string( $keyspace ) && $keyspace !== '' ) { return $keyspace; } - $keyspace = $wgDBname; - if ( is_string( $wgDBprefix ) && $wgDBprefix !== '' ) { - $keyspace .= '-' . $wgDBprefix; - } - - return $keyspace; + return wfWikiID(); } /** @@ -167,8 +162,6 @@ class ObjectCache { if ( isset( $params['loggroup'] ) ) { $params['logger'] = LoggerFactory::getInstance( $params['loggroup'] ); } else { - // For backwards-compatability with custom parameters, lets not - // have all logging suddenly disappear $params['logger'] = LoggerFactory::getInstance( 'objectcache' ); } if ( !isset( $params['keyspace'] ) ) { @@ -178,8 +171,26 @@ class ObjectCache { return call_user_func( $params['factory'], $params ); } elseif ( isset( $params['class'] ) ) { $class = $params['class']; - if ( $class === 'MultiWriteBagOStuff' && !isset( $params['asyncHandler'] ) ) { - $params['asyncHandler'] = 'DeferredUpdates::addCallableUpdate'; + // Automatically set the 'async' update handler + if ( $class === 'MultiWriteBagOStuff' ) { + $params['asyncHandler'] = isset( $params['asyncHandler'] ) + ? $params['asyncHandler'] + : 'DeferredUpdates::addCallableUpdate'; + } + // Do b/c logic for MemcachedBagOStuff + if ( is_subclass_of( $class, 'MemcachedBagOStuff' ) ) { + if ( !isset( $params['servers'] ) ) { + $params['servers'] = $GLOBALS['wgMemCachedServers']; + } + if ( !isset( $params['debug'] ) ) { + $params['debug'] = $GLOBALS['wgMemCachedDebug']; + } + if ( !isset( $params['persistent'] ) ) { + $params['persistent'] = $GLOBALS['wgMemCachedPersistent']; + } + if ( !isset( $params['timeout'] ) ) { + $params['timeout'] = $GLOBALS['wgMemCachedTimeout']; + } } return new $class( $params ); } else { @@ -253,21 +264,7 @@ class ObjectCache { } $id = $fallback; } - return self::newFromId( $id ); - } - - /** - * Factory function that creates a memcached client object. - * - * This always uses the PHP client, since the PECL client has a different - * hashing scheme and a different interpretation of the flags bitfield, so - * switching between the two clients randomly would be disastrous. - * - * @param array $params - * @return MemcachedPhpBagOStuff - */ - public static function newMemcached( $params ) { - return new MemcachedPhpBagOStuff( $params ); + return self::getInstance( $id ); } /** @@ -290,6 +287,11 @@ class ObjectCache { $class = $params['relayerConfig']['class']; $params['relayer'] = new $class( $params['relayerConfig'] ); $params['cache'] = self::newFromId( $params['cacheId'] ); + if ( isset( $params['loggroup'] ) ) { + $params['logger'] = LoggerFactory::getInstance( $params['loggroup'] ); + } else { + $params['logger'] = LoggerFactory::getInstance( 'objectcache' ); + } $class = $params['class']; return new $class( $params );