/**
* See documentation of $wgPasswordAttemptThrottle for format. Old (pre-1.27) format is not
* allowed here.
- * @var array
+ * @var array[]
* @see https://www.mediawiki.org/wiki/Manual:$wgPasswordAttemptThrottle
*/
protected $conditions;
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,
// @codeCoverageIgnoreEnd
] );
- return [
- 'throttleIndex' => $index,
- 'count' => $count,
- 'wait' => $expiry,
- ];
+ return [ 'throttleIndex' => $index, 'count' => $count, 'wait' => $expiry ];
+ } else {
+ $this->cache->incrWithInit( $throttleKey, $expiry, 1 );
}
}
+
return false;
}
/**
* Handles B/C for $wgPasswordAttemptThrottle.
* @param array $throttleConditions
- * @return array
+ * @return array[]
* @see $wgPasswordAttemptThrottle for structure
*/
protected static function normalizeThrottleConditions( $throttleConditions ) {