X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fauth%2FThrottler.php;h=9d0175ada9a3cc16a3bfcf700b1260344516d720;hb=1879bf796a572ab07a397e91749978ea955eb177;hp=e6d9bd8de982f50ba4b3ec04bfe07c9c794c4a71;hpb=af363e85a0de038a4349de5f5bef22fc06cc998b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/auth/Throttler.php b/includes/auth/Throttler.php index e6d9bd8de9..9d0175ada9 100644 --- a/includes/auth/Throttler.php +++ b/includes/auth/Throttler.php @@ -127,14 +127,16 @@ class Throttler implements LoggerAwareInterface { continue; } - $throttleKey = $this->cache->makeGlobalKey( 'throttler', $this->type, $index, $ipKey, $userKey ); + $throttleKey = $this->cache->makeGlobalKey( + 'throttler', + $this->type, + $index, + $ipKey, + $userKey + ); $throttleCount = $this->cache->get( $throttleKey ); - - if ( !$throttleCount ) { // counter not started yet - $this->cache->add( $throttleKey, 1, $expiry ); - } elseif ( $throttleCount < $count ) { // throttle limited not yet reached - $this->cache->incr( $throttleKey ); - } else { // throttled + if ( $throttleCount && $throttleCount >= $count ) { + // Throttle limited reached $this->logRejection( [ 'throttle' => $this->type, 'index' => $index, @@ -147,13 +149,12 @@ class Throttler implements LoggerAwareInterface { // @codeCoverageIgnoreEnd ] ); - return [ - 'throttleIndex' => $index, - 'count' => $count, - 'wait' => $expiry, - ]; + return [ 'throttleIndex' => $index, 'count' => $count, 'wait' => $expiry ]; + } else { + $this->cache->incrWithInit( $throttleKey, $expiry, 1 ); } } + return false; }