Bug: T168242
Change-Id: I9b57b8bcfdcb823adb89213518abfdfb834ef223
protected static function resetGlobalServices( Config $bootstrapConfig = null ) {
$oldServices = MediaWikiServices::getInstance();
$oldConfigFactory = $oldServices->getConfigFactory();
protected static function resetGlobalServices( Config $bootstrapConfig = null ) {
$oldServices = MediaWikiServices::getInstance();
$oldConfigFactory = $oldServices->getConfigFactory();
+ $oldLoadBalancerFactory = $oldServices->getDBLoadBalancerFactory();
$testConfig = self::makeTestConfig( $bootstrapConfig );
$testConfig = self::makeTestConfig( $bootstrapConfig );
$serviceLocator = MediaWikiServices::getInstance();
self::installTestServices(
$oldConfigFactory,
$serviceLocator = MediaWikiServices::getInstance();
self::installTestServices(
$oldConfigFactory,
+ $oldLoadBalancerFactory,
$serviceLocator
);
return $serviceLocator;
$serviceLocator
);
return $serviceLocator;
/**
* @param ConfigFactory $oldConfigFactory
/**
* @param ConfigFactory $oldConfigFactory
+ * @param LBFactory $oldLoadBalancerFactory
* @param MediaWikiServices $newServices
*
* @throws MWException
*/
private static function installTestServices(
ConfigFactory $oldConfigFactory,
* @param MediaWikiServices $newServices
*
* @throws MWException
*/
private static function installTestServices(
ConfigFactory $oldConfigFactory,
+ LBFactory $oldLoadBalancerFactory,
MediaWikiServices $newServices
) {
// Use bootstrap config for all configuration.
MediaWikiServices $newServices
) {
// Use bootstrap config for all configuration.
[ 'main' => $bootstrapConfig ]
)
);
[ 'main' => $bootstrapConfig ]
)
);
+ $newServices->resetServiceForTesting( 'DBLoadBalancerFactory' );
+ $newServices->redefineService(
+ 'DBLoadBalancerFactory',
+ function ( MediaWikiServices $services ) use ( $oldLoadBalancerFactory ) {
+ return $oldLoadBalancerFactory;
+ }
+ );
$oldInstance = MediaWikiServices::getInstance();
$oldConfigFactory = $oldInstance->getConfigFactory();
$oldInstance = MediaWikiServices::getInstance();
$oldConfigFactory = $oldInstance->getConfigFactory();
+ $oldLoadBalancerFactory = $oldInstance->getDBLoadBalancerFactory();
$testConfig = self::makeTestConfig( null, $configOverrides );
$newInstance = new MediaWikiServices( $testConfig );
$testConfig = self::makeTestConfig( null, $configOverrides );
$newInstance = new MediaWikiServices( $testConfig );
self::installTestServices(
$oldConfigFactory,
self::installTestServices(
$oldConfigFactory,
+ $oldLoadBalancerFactory,
$newInstance
);
MediaWikiServices::forceGlobalInstance( $newInstance );
$newInstance
);
MediaWikiServices::forceGlobalInstance( $newInstance );