},
'LocalServerObjectCache' => function ( MediaWikiServices $services ) : BagOStuff {
+ $config = $services->getMainConfig();
$cacheId = \ObjectCache::detectLocalServerCache();
- return \ObjectCache::newFromId( $cacheId );
+ return \ObjectCache::newFromParams( $config->get( 'ObjectCaches' )[$cacheId] );
},
'MagicWordFactory' => function ( MediaWikiServices $services ) : MagicWordFactory {
* @return BagOStuff
* @throws InvalidArgumentException
*/
- public static function newFromId( $id ) {
+ private static function newFromId( $id ) {
global $wgObjectCaches;
if ( !isset( $wgObjectCaches[$id] ) ) {
*
* @return string
*/
- public static function getDefaultKeyspace() {
+ private static function getDefaultKeyspace() {
global $wgCachePrefix;
$keyspace = $wgCachePrefix;
* @return WANObjectCache
* @throws UnexpectedValueException
*/
- public static function newWANCacheFromId( $id ) {
+ private static function newWANCacheFromId( $id ) {
global $wgWANObjectCaches, $wgObjectCaches;
if ( !isset( $wgWANObjectCaches[$id] ) ) {
* be loaded then).
*/
public function loadFromQueue() {
- global $wgVersion, $wgDevelopmentWarnings;
+ global $wgVersion, $wgDevelopmentWarnings, $wgObjectCaches;
if ( !$this->queued ) {
return;
}
// We use a try/catch because we don't want to fail here
// if $wgObjectCaches is not configured properly for APC setup
try {
- // Don't use MediaWikiServices here to prevent instantiating it before extensions have
- // been loaded
+ // Avoid MediaWikiServices to prevent instantiating it before extensions have loaded
$cacheId = ObjectCache::detectLocalServerCache();
- $cache = ObjectCache::newFromId( $cacheId );
+ $cache = ObjectCache::newFromParams( $wgObjectCaches[$cacheId] );
} catch ( InvalidArgumentException $e ) {
$cache = new EmptyBagOStuff();
}
// type defined through parameter
if ( $this->getCliArg( 'use-bagostuff' ) !== null ) {
- $name = $this->getCliArg( 'use-bagostuff' );
+ global $wgObjectCaches;
- $this->cache = ObjectCache::newFromId( $name );
+ $id = $this->getCliArg( 'use-bagostuff' );
+ $this->cache = ObjectCache::newFromParams( $wgObjectCaches[$id] );
} else {
// no type defined - use simple hash
$this->cache = new HashBagOStuff;
* @covers MediumSpecificBagOStuff::makeKeyInternal
*/
public function testMakeKey() {
- $cache = ObjectCache::newFromId( 'hash' );
+ $cache = new HashBagOStuff();
$localKey = $cache->makeKey( 'first', 'second', 'third' );
$globalKey = $cache->makeGlobalKey( 'first', 'second', 'third' );