$ php maintenance/eval.php
> $wgMessageCacheType = CACHE_ACCEL;
> wfGetMessageCacheStorage();
PHP Warning: Illegal offset type in isset or empty in includes/objectcache/ObjectCache.php on line 93
PHP Warning: Illegal offset type in isset or empty in includes/objectcache/ObjectCache.php on line 125
PHP Notice: Array to string conversion in includes/objectcache/ObjectCache.php on line 133
Caught exception InvalidArgumentException: Invalid object cache type "Array" requested. It is not present in $wgObjectCaches.
#0 includes/objectcache/ObjectCache.php(94): ObjectCache::newFromId(Array)
#1 includes/objectcache/ObjectCache.php(287): ObjectCache::getInstance(Array)
#2 [internal function]: ObjectCache::getLocalServerInstance(Array)
#3 includes/objectcache/ObjectCache.php(181): call_user_func('ObjectCache::ge...', Array)
#4 includes/objectcache/ObjectCache.php(137): ObjectCache::newFromParams(Array)
#5 includes/objectcache/ObjectCache.php(94): ObjectCache::newFromId(3)
#6 includes/GlobalFunctions.php(3430): ObjectCache::getInstance(3)
#7 maintenance/eval.php(78) : eval()'d code(1): wfGetMessageCacheStorage()
#8 maintenance/eval.php(78): eval()
#9 {main}
This reverts commit
6d99fa58247a1de7eaf9a79a061f0b4207154072.
Change-Id: I4d756eb6f66318a12d8cbbc1ba546397be8a29bf
return $this->getService( 'TitleParser' );
}
- /**
- * @since 1.28
- * @return \BagOStuff
- */
- public function getMainObjectStash() {
- return $this->getService( 'MainObjectStash' );
- }
-
- /**
- * @since 1.28
- * @return \WANObjectCache
- */
- public function getMainWANObjectCache() {
- return $this->getService( 'MainWANObjectCache' );
- }
-
- /**
- * @since 1.28
- * @return \BagOStuff
- */
- public function getLocalServerObjectCache() {
- return $this->getService( 'LocalServerObjectCache' );
- }
-
/**
* @since 1.28
* @return VirtualRESTServiceClient
return $services->getService( '_MediaWikiTitleCodec' );
},
- 'MainObjectStash' => function( MediaWikiServices $services ) {
- $mainConfig = $services->getMainConfig();
-
- $id = $mainConfig->get( 'MainStash' );
- if ( !isset( $mainConfig->get( 'ObjectCaches' )[$id] ) ) {
- throw new UnexpectedValueException(
- "Cache type \"$id\" is not present in \$wgObjectCaches." );
- }
-
- return \ObjectCache::newFromParams( $mainConfig->get( 'ObjectCaches' )[$id] );
- },
-
- 'MainWANObjectCache' => function( MediaWikiServices $services ) {
- $mainConfig = $services->getMainConfig();
-
- $id = $mainConfig->get( 'MainWANCache' );
- if ( !isset( $mainConfig->get( 'WANObjectCaches' )[$id] ) ) {
- throw new UnexpectedValueException(
- "WAN cache type \"$id\" is not present in \$wgWANObjectCaches." );
- }
-
- $params = $mainConfig->get( 'WANObjectCaches' )[$id];
- $objectCacheId = $params['cacheId'];
- if ( !isset( $mainConfig->get( 'ObjectCaches' )[$objectCacheId] ) ) {
- throw new UnexpectedValueException(
- "Cache type \"$objectCacheId\" is not present in \$wgObjectCaches." );
- }
- $params['store'] = $mainConfig->get( 'ObjectCaches' )[$objectCacheId];
-
- return \ObjectCache::newWANCacheFromParams( $params );
- },
-
- 'LocalServerObjectCache' => function( MediaWikiServices $services ) {
- $mainConfig = $services->getMainConfig();
-
- if ( function_exists( 'apc_fetch' ) ) {
- $id = 'apc';
- } elseif ( function_exists( 'xcache_get' ) && wfIniGetBool( 'xcache.var_size' ) ) {
- $id = 'xcache';
- } 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] );
- },
-
'VirtualRESTServiceClient' => function( MediaWikiServices $services ) {
$config = $services->getMainConfig()->get( 'VirtualRestConfig' );
* // From $wgObjectCaches via newFromParams()
* ObjectCache::getLocalServerInstance( [ 'fallback' => $fallbackType ] );
*
- * @param int|string $fallback Fallback cache ID
+ * @param int|string|array $fallback Fallback cache or parameter map with 'fallback'
* @return BagOStuff
* @throws InvalidArgumentException
* @since 1.27
- * @deprecated Since 1.28; use MediaWikiServices::getLocalServerObjectCache
*/
public static function getLocalServerInstance( $fallback = CACHE_NONE ) {
- $cache = MediaWikiServices::getInstance()->getLocalServerObjectCache();
+ if ( function_exists( 'apc_fetch' ) ) {
+ $id = 'apc';
+ } elseif ( function_exists( 'xcache_get' ) && wfIniGetBool( 'xcache.var_size' ) ) {
+ $id = 'xcache';
+ } elseif ( function_exists( 'wincache_ucache_get' ) ) {
+ $id = 'wincache';
+ } else {
+ if ( is_array( $fallback ) ) {
+ $id = isset( $fallback['fallback'] ) ? $fallback['fallback'] : CACHE_NONE;
+ } else {
+ $id = $fallback;
+ }
+ }
- return ( $cache instanceof EmptyBagOStuff )
- ? self::getInstance( $fallback )
- : $cache;
+ return self::getInstance( $id );
}
/**
*
* @since 1.26
* @return WANObjectCache
- * @deprecated Since 1.28 Use MediaWikiServices::getMainWANCache()
*/
public static function getMainWANInstance() {
- return MediaWikiServices::getInstance()->getMainWANObjectCache();
+ global $wgMainWANCache;
+
+ return self::getWANInstance( $wgMainWANCache );
}
/**
*
* @return BagOStuff
* @since 1.26
- * @deprecated Since 1.28 Use MediaWikiServices::getMainObjectStash
*/
public static function getMainStashInstance() {
- return MediaWikiServices::getInstance()->getMainObjectStash();
+ global $wgMainStash;
+
+ return self::getInstance( $wgMainStash );
}
/**
JobQueueGroup::destroySingletons();
ObjectCache::clear();
- $services = MediaWikiServices::getInstance();
- $services->resetServiceForTesting( 'MainObjectStash' );
- $services->resetServiceForTesting( 'LocalServerObjectCache' );
- $services->getMainWANObjectCache()->clearProcessCache();
FileBackendGroup::destroySingleton();
// TODO: move global state into MediaWikiServices
'_MediaWikiTitleCodec' => [ '_MediaWikiTitleCodec', MediaWikiTitleCodec::class ],
'TitleFormatter' => [ 'TitleFormatter', TitleFormatter::class ],
'TitleParser' => [ 'TitleParser', TitleParser::class ],
- 'ProxyLookup' => [ 'ProxyLookup', ProxyLookup::class ],
- 'MainObjectStash' => [ 'MainObjectStash', BagOStuff::class ],
- 'MainWANObjectCache' => [ 'MainWANObjectCache', WANObjectCache::class ],
- 'LocalServerObjectCache' => [ 'LocalServerObjectCache', BagOStuff::class ],
- 'VirtualRESTServiceClient' => [ 'VirtualRESTServiceClient', VirtualRESTServiceClient::class ]
+ 'VirtualRESTServiceClient' => [ 'VirtualRESTServiceClient', VirtualRESTServiceClient::class ],
+ 'ProxyLookup' => [ 'ProxyLookup', ProxyLookup::class ]
];
}