Skip to content

Conversation

@faisuc
Copy link
Contributor

@faisuc faisuc commented Dec 25, 2025

Fixes #58014.

PR #57851 changed RateLimiter::remaining() to use max(0, $maxAttempts - $attempts) to prevent negative values when attempts exceed the limit. This broke cases where $maxAttempts is negative.
Before PR #57851, remaining('key', -1) returned a negative number, so !remaining('key', -1) was false. After the change, it returned 0, so !remaining('key', -1) became true, which is incorrect.
This fix checks if $maxAttempts >= 0 before applying the max() clamp. For negative values, it returns -1 to indicate unlimited attempts, restoring the previous behavior while keeping the fix for non-negative values.
The change preserves PR #57851's behavior for normal cases and restores the ability to disable rate limiting with negative values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Changes in RateLimiter::remaining altered behaviour for negative values of $maxAttempts parameter

1 participant