use MediaWiki\Interwiki\ClassicInterwikiLookup;
use MediaWiki\Linker\LinkRendererFactory;
+use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MediaWikiServices;
return [
return new WatchedItemQueryService( $services->getDBLoadBalancer() );
},
+ 'CryptRand' => function( MediaWikiServices $services ) {
+ $secretKey = $services->getMainConfig()->get( 'SecretKey' );
+ return new CryptRand(
+ [
+ // To try vary the system information of the state a bit more
+ // by including the system's hostname into the state
+ 'wfHostname',
+ // It's mostly worthless but throw the wiki's id into the data
+ // for a little more variance
+ 'wfWikiID',
+ // If we have a secret key set then throw it into the state as well
+ function() use ( $secretKey ) {
+ return $secretKey ?: '';
+ }
+ ],
+ // The config file is likely the most often edited file we know should
+ // be around so include its stat info into the state.
+ // The constant with its location will almost always be defined, as
+ // WebStart.php defines MW_CONFIG_FILE to $IP/LocalSettings.php unless
+ // being configured with MW_CONFIG_CALLBACK (e.g. the installer).
+ defined( 'MW_CONFIG_FILE' ) ? [ MW_CONFIG_FILE ] : [],
+ LoggerFactory::getInstance( 'CryptRand' )
+ );
+ },
+
+ 'CryptHKDF' => function( MediaWikiServices $services ) {
+ $config = $services->getMainConfig();
+
+ $secret = $config->get( 'HKDFSecret' ) ?: $config->get( 'SecretKey' );
+ if ( !$secret ) {
+ throw new RuntimeException( "Cannot use MWCryptHKDF without a secret." );
+ }
+
+ // In HKDF, the context can be known to the attacker, but this will
+ // keep simultaneous runs from producing the same output.
+ $context = [ microtime(), getmypid(), gethostname() ];
+
+ // Setup salt cache. Use APC, or fallback to the main cache if it isn't setup
+ $cache = $services->getLocalServerObjectCache();
+ if ( $cache instanceof EmptyBagOStuff ) {
+ $cache = ObjectCache::getLocalClusterInstance();
+ }
+
+ return new CryptHKDF( $secret, $config->get( 'HKDFAlgorithm' ),
+ $cache, $context, $services->getCryptRand()
+ );
+ },
+
'MediaHandlerFactory' => function( MediaWikiServices $services ) {
return new MediaHandlerFactory(
$services->getMainConfig()->get( 'MediaHandlers' )
);
},
+ 'MimeAnalyzer' => function( MediaWikiServices $services ) {
+ return new MimeMagic(
+ MimeMagic::applyDefaultParameters(
+ [],
+ $services->getMainConfig()
+ )
+ );
+ },
+
'ProxyLookup' => function( MediaWikiServices $services ) {
$mainConfig = $services->getMainConfig();
return new ProxyLookup(
);
},
+ 'Parser' => function( MediaWikiServices $services ) {
+ $conf = $services->getMainConfig()->get( 'ParserConf' );
+ return ObjectFactory::constructClassInstance( $conf['class'], [ $conf ] );
+ },
+
'LinkCache' => function( MediaWikiServices $services ) {
return new LinkCache(
$services->getTitleFormatter(),
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( 'apcu_fetch' ) ) {
+ $id = 'apcu';
+ } 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' );