Merge "wgRateLimits: Add configuration option to ignore 'noratelimit' right"
[lhc/web/wiklou.git] / includes / ServiceWiring.php
index 8c7d802..86f4578 100644 (file)
 
 use MediaWiki\Interwiki\ClassicInterwikiLookup;
 use MediaWiki\Linker\LinkRendererFactory;
+use MediaWiki\Logger\LoggerFactory;
 use MediaWiki\MediaWikiServices;
 
 return [
        'DBLoadBalancerFactory' => function( MediaWikiServices $services ) {
                $mainConfig = $services->getMainConfig();
 
-               $lbConf = LBFactoryMW::applyDefaultConfig(
+               $lbConf = MWLBFactory::applyDefaultConfig(
                        $mainConfig->get( 'LBFactoryConf' ),
                        $mainConfig
                );
-               $class = LBFactoryMW::getLBFactoryClass( $lbConf );
+               $class = MWLBFactory::getLBFactoryClass( $lbConf );
 
                return new $class( $lbConf );
        },
@@ -158,12 +159,45 @@ 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' )
+               );
+       },
+
        'MediaHandlerFactory' => function( MediaWikiServices $services ) {
                return new MediaHandlerFactory(
                        $services->getMainConfig()->get( 'MediaHandlers' )
                );
        },
 
+       'ProxyLookup' => function( MediaWikiServices $services ) {
+               $mainConfig = $services->getMainConfig();
+               return new ProxyLookup(
+                       $mainConfig->get( 'SquidServers' ),
+                       $mainConfig->get( 'SquidServersNoPurge' )
+               );
+       },
+
        'LinkCache' => function( MediaWikiServices $services ) {
                return new LinkCache(
                        $services->getTitleFormatter(),