mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-11-27 17:40:11 +00:00
Use ObjectCacheFactory methods
Bug: T363770 Change-Id: I66ffd2d559a22c72a72b1f664a9332900704d503
This commit is contained in:
parent
47dffc154b
commit
4e0570e5cf
|
@ -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 );
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue