/** * @dataProvider getLBFactoryClassProvider */ public function testGetLBFactoryClass($expected, $deprecated) { $mockDB = $this->getMockBuilder('DatabaseMysql')->disableOriginalConstructor()->getMock(); $config = ['class' => $deprecated, 'connection' => $mockDB, 'sectionsByDB' => [], 'sectionLoads' => [], 'serverTemplate' => []]; $this->hideDeprecated('$wgLBFactoryConf must be updated. See RELEASE-NOTES for details'); $result = MWLBFactory::getLBFactoryClass($config); $this->assertEquals($expected, $result); }
* The services defined here do not yet fully represent all services used by core, * much of the code still relies on global state for this accessing services. * * @since 1.27 * * @see docs/injection.txt for an overview of using dependency injection in the * MediaWiki code base. */ use MediaWiki\Interwiki\ClassicInterwikiLookup; use MediaWiki\Linker\LinkRendererFactory; use MediaWiki\Logger\LoggerFactory; use MediaWiki\MediaWikiServices; return ['DBLoadBalancerFactory' => function (MediaWikiServices $services) { $mainConfig = $services->getMainConfig(); $lbConf = MWLBFactory::applyDefaultConfig($mainConfig->get('LBFactoryConf'), $mainConfig); $class = MWLBFactory::getLBFactoryClass($lbConf); return new $class($lbConf); }, 'DBLoadBalancer' => function (MediaWikiServices $services) { // just return the default LB from the DBLoadBalancerFactory service return $services->getDBLoadBalancerFactory()->getMainLB(); }, 'SiteStore' => function (MediaWikiServices $services) { $rawSiteStore = new DBSiteStore($services->getDBLoadBalancer()); // TODO: replace wfGetCache with a CacheFactory service. // TODO: replace wfIsHHVM with a capabilities service. $cache = wfGetCache(wfIsHHVM() ? CACHE_ACCEL : CACHE_ANYTHING); return new CachingSiteStore($rawSiteStore, $cache); }, 'SiteLookup' => function (MediaWikiServices $services) { // Use the default SiteStore as the SiteLookup implementation for now return $services->getSiteStore(); }, 'ConfigFactory' => function (MediaWikiServices $services) { // Use the bootstrap config to initialize the ConfigFactory.