Fix ConfirmEdit to avoid global state

ConfirmEdit will try to mess with ObjectCache::$instances, clean this
up so that we migrate consumers to go through ObjectCacheFactory.

Bug: T358346
Change-Id: I317a1a17f4f39e99a9b31660eebcd0185adb88f8
This commit is contained in:
Derick Alangi 2024-03-07 14:56:45 +03:00
parent 43f2f36462
commit 5b3765f7b5
No known key found for this signature in database
GPG key ID: 01D205B3F82BADDA

View file

@ -9,7 +9,6 @@ use MediaWiki\Extension\ConfirmEdit\Hooks;
use MediaWiki\Extension\ConfirmEdit\SimpleCaptcha\SimpleCaptcha;
use MediaWiki\Extension\ConfirmEdit\Store\CaptchaHashStore;
use MediaWiki\Extension\ConfirmEdit\Store\CaptchaStore;
use MediaWiki\MediaWikiServices;
use MediaWiki\Request\FauxRequest;
use MediaWiki\Tests\Unit\Auth\AuthenticationProviderTestTrait;
use MediaWiki\User\User;
@ -29,15 +28,10 @@ class CaptchaPreAuthenticationProviderTest extends MediaWikiIntegrationTestCase
'wgCaptchaBadLoginAttempts' => 1,
'wgCaptchaBadLoginPerUserAttempts' => 1,
'wgCaptchaStorageClass' => CaptchaHashStore::class,
'wgMainCacheType' => __METHOD__,
'wgMainCacheType' => 'hash',
] );
CaptchaStore::unsetInstanceForTests();
CaptchaStore::get()->clearAll();
$services = MediaWikiServices::getInstance();
if ( method_exists( $services, 'getLocalClusterObjectCache' ) ) {
$this->setService( 'LocalClusterObjectCache', new HashBagOStuff() );
}
ObjectCache::$instances[__METHOD__] = new HashBagOStuff();
}
public function tearDown(): void {