* Use services container in more places.
* Undeprecated getLocalServerInstance() since $fallback is not
handled elsewhere.
Change-Id: Id1fcd1c465d2d92653357523f4225f1c4d1ace2f
* @file
* @ingroup Cache
*/
+use MediaWiki\MediaWikiServices;
/**
* MediaWiki message cache structure version.
$this->mExpiry = $expiry;
if ( $wgUseLocalMessageCache ) {
- $this->localCache = ObjectCache::getLocalServerInstance( CACHE_NONE );
+ $this->localCache = MediaWikiServices::getInstance()->getLocalServerObjectCache();
} else {
- $this->localCache = wfGetCache( CACHE_NONE );
+ $this->localCache = new EmptyBagOStuff();
}
$this->wanCache = ObjectCache::getMainWANInstance();
*/
use MediaWiki\Logger\LoggerFactory;
+use MediaWiki\MediaWikiServices;
/**
* MediaWiki-specific class for generating database load balancers
}
// Use APC/memcached style caching, but avoids loops with CACHE_DB (T141804)
- $sCache = ObjectCache::getLocalServerInstance();
+ $sCache = MediaWikiServices::getInstance()->getLocalServerObjectCache();
if ( $sCache->getQoS( $sCache::ATTR_EMULATION ) > $sCache::QOS_EMULATION_SQL ) {
$lbConf['srvCache'] = $sCache;
}
if ( $cCache->getQoS( $cCache::ATTR_EMULATION ) > $cCache::QOS_EMULATION_SQL ) {
$lbConf['memCache'] = $cCache;
}
- $wCache = ObjectCache::getMainWANInstance();
+ $wCache = MediaWikiServices::getInstance()->getMainWANObjectCache();
if ( $wCache->getQoS( $wCache::ATTR_EMULATION ) > $wCache::QOS_EMULATION_SQL ) {
$lbConf['wanCache'] = $wCache;
}
* @author Aaron Schulz
*/
use \MediaWiki\Logger\LoggerFactory;
+use MediaWiki\MediaWikiServices;
/**
* Class to handle file backend registration
'streamMimeFunc' => [ 'StreamFile', 'contentTypeFromPath' ],
'tmpDirectory' => wfTempDir(),
'statusWrapper' => [ 'Status', 'wrap' ],
- 'wanCache' => ObjectCache::getMainWANInstance(),
+ 'wanCache' => MediaWikiServices::getInstance()->getMainWANObjectCache(),
'srvCache' => ObjectCache::getLocalServerInstance( 'hash' ),
'logger' => LoggerFactory::getInstance( 'FileOperation' ),
'profiler' => Profiler::instance()
* @file
* @ingroup Media
*/
+use MediaWiki\MediaWikiServices;
/**
* Handler for images that need to be transformed
* @return string|bool Representing the IM version; false on error
*/
protected function getMagickVersion() {
- $cache = ObjectCache::getLocalServerInstance( CACHE_NONE );
+ $cache = MediaWikiServices::getInstance()->getLocalServerObjectCache();
return $cache->getWithSetCallback(
'imagemagick-version',
$cache::TTL_HOUR,
<?php
+use MediaWiki\MediaWikiServices;
+
/**
* ExtensionRegistry class
*
// we don't want to fail here if $wgObjectCaches is not configured
// properly for APC setup
try {
- $this->cache = ObjectCache::getLocalServerInstance();
+ $this->cache = MediaWikiServices::getInstance()->getLocalServerObjectCache();
} catch ( MWException $e ) {
$this->cache = new EmptyBagOStuff();
}
* @author Chris Steipp
* @file
*/
+use MediaWiki\MediaWikiServices;
class MWCryptHKDF {
* @throws MWException
*/
protected static function singleton() {
- global $wgHKDFAlgorithm, $wgHKDFSecret, $wgSecretKey, $wgMainCacheType;
+ global $wgHKDFAlgorithm, $wgHKDFSecret, $wgSecretKey;
$secret = $wgHKDFSecret ?: $wgSecretKey;
if ( !$secret ) {
$context[] = getmypid();
$context[] = gethostname();
- // Setup salt cache. Use APC, or fallback to the main cache if it isn't setup
- $cache = ObjectCache::getLocalServerInstance( $wgMainCacheType );
+ // Setup salt cache
+ $cache = MediaWikiServices::getInstance()->getLocalServerObjectCache();
+ if ( $cache instanceof EmptyBagOStuff ) {
+ // Use APC, or fallback to the main cache if it isn't setup
+ $cache = ObjectCache::getLocalClusterInstance();
+ }
if ( is_null( self::$singleton ) ) {
self::$singleton = new self( $secret, $wgHKDFAlgorithm, $cache, $context );
* @author Aaron Schulz
*/
use Wikimedia\Assert\Assert;
+use MediaWiki\MediaWikiServices;
/**
* Class for getting statistically unique IDs
// Counter values would not survive accross script instances in CLI mode.
$cache = null;
if ( ( $flags & self::QUICK_VOLATILE ) && PHP_SAPI !== 'cli' ) {
- $cache = ObjectCache::getLocalServerInstance();
+ $cache = MediaWikiServices::getInstance()->getLocalServerObjectCache();
}
if ( $cache ) {
$counter = $cache->incrWithInit( $bucket, $cache::TTL_INDEFINITE, $count, $count );