mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-11-23 15:56:50 +00:00
Merge "Use ObjectCacheFactory methods"
This commit is contained in:
commit
0b648c2348
|
@ -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