Merge "Use ObjectCacheFactory methods"

This commit is contained in:
jenkins-bot 2024-06-13 13:50:57 +00:00 committed by Gerrit Code Review
commit 0b648c2348
2 changed files with 7 additions and 9 deletions

View file

@ -16,7 +16,6 @@ use MediaWiki\SpecialPage\SpecialPage;
use MediaWiki\Utils\MWTimestamp;
use MediaWiki\WikiMap\WikiMap;
use NullLockManager;
use ObjectCache;
use StatusValue;
use UnderflowException;
@ -223,7 +222,7 @@ class FancyCaptcha extends SimpleCaptcha {
}
$backend = $this->getBackend();
$cache = ObjectCache::getLocalClusterInstance();
$cache = MediaWikiServices::getInstance()->getObjectCacheFactory()->getLocalClusterInstance();
$key = $cache->makeGlobalKey(
'fancycaptcha-dirlist',
@ -283,7 +282,7 @@ class FancyCaptcha extends SimpleCaptcha {
*/
protected function pickImageFromDir( $directory, &$lockouts ) {
$backend = $this->getBackend();
$cache = ObjectCache::getLocalClusterInstance();
$cache = MediaWikiServices::getInstance()->getObjectCacheFactory()->getLocalClusterInstance();
$key = $cache->makeGlobalKey(
'fancycaptcha-filelist',
@ -341,7 +340,7 @@ class FancyCaptcha extends SimpleCaptcha {
}
$backend = $this->getBackend();
$cache = ObjectCache::getLocalClusterInstance();
$cache = MediaWikiServices::getInstance()->getObjectCacheFactory()->getLocalClusterInstance();
// pick a random file
$place = mt_rand( 0, count( $files ) - 1 );

View file

@ -8,7 +8,6 @@ use MediaWiki\Extension\ConfirmEdit\SimpleCaptcha\SimpleCaptcha;
use MediaWiki\MediaWikiServices;
use MediaWiki\User\User;
use MediaWiki\User\UserNameUtils;
use ObjectCache;
/**
* Helper to count login attempts per IP and per username.
@ -31,7 +30,7 @@ class LoginAttemptCounter {
public function increaseBadLoginCounter( $username ) {
global $wgCaptchaBadLoginExpiration, $wgCaptchaBadLoginPerUserExpiration;
$cache = ObjectCache::getLocalClusterInstance();
$cache = MediaWikiServices::getInstance()->getObjectCacheFactory()->getLocalClusterInstance();
if ( $this->captcha->triggersCaptcha( CaptchaTriggers::BAD_LOGIN ) ) {
$key = $this->badLoginKey( $cache );
@ -50,7 +49,7 @@ class LoginAttemptCounter {
*/
public function resetBadLoginCounter( $username ) {
if ( $this->captcha->triggersCaptcha( CaptchaTriggers::BAD_LOGIN_PER_USER ) && $username ) {
$cache = ObjectCache::getLocalClusterInstance();
$cache = MediaWikiServices::getInstance()->getObjectCacheFactory()->getLocalClusterInstance();
$cache->delete( $this->badLoginPerUserKey( $username, $cache ) );
}
}
@ -63,7 +62,7 @@ class LoginAttemptCounter {
public function isBadLoginTriggered() {
global $wgCaptchaBadLoginAttempts;
$cache = ObjectCache::getLocalClusterInstance();
$cache = MediaWikiServices::getInstance()->getObjectCacheFactory()->getLocalClusterInstance();
return $this->captcha->triggersCaptcha( CaptchaTriggers::BAD_LOGIN )
&& (int)$cache->get( $this->badLoginKey( $cache ) ) >= $wgCaptchaBadLoginAttempts;
}
@ -77,7 +76,7 @@ class LoginAttemptCounter {
public function isBadLoginPerUserTriggered( $u ) {
global $wgCaptchaBadLoginPerUserAttempts;
$cache = ObjectCache::getLocalClusterInstance();
$cache = MediaWikiServices::getInstance()->getObjectCacheFactory()->getLocalClusterInstance();
if ( is_object( $u ) ) {
$u = $u->getName();