Fix: Use ObjectCacheFactory instead of deprecated ObjectCache Methods

Bug: T363770
Change-Id: Ie7a237c100560933ce7b6b846ddee147bd858405
This commit is contained in:
Wandji69 2024-05-20 23:09:01 +01:00
parent 7cc8841f50
commit 46a4453f8d

View file

@ -30,7 +30,6 @@ use MediaWiki\Extension\OATHAuth\OATHUser;
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\MediaWikiServices;
use MWException;
use ObjectCache;
use Psr\Log\LoggerInterface;
/**
@ -132,11 +131,12 @@ class TOTPKey implements IAuthKey {
}
// Prevent replay attacks
$store = MediaWikiServices::getInstance()->getMainObjectStash();
$services = MediaWikiServices::getInstance();
$store = $services->getMainObjectStash();
if ( $store instanceof EmptyBagOStuff ) {
// Try and find some usable cache if the MainObjectStash isn't useful
$store = ObjectCache::getLocalServerInstance( CACHE_ANYTHING );
$store = $services->getObjectCacheFactory()->getLocalServerInstance( CACHE_ANYTHING );
}
$key = $store->makeKey( 'oathauth-totp', 'usedtokens', $user->getCentralId() );