Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RateLimiter] Fix infinite values with NoLimiter #39911

Merged
merged 1 commit into from Jan 23, 2021

Conversation

YaFou
Copy link
Contributor

@YaFou YaFou commented Jan 20, 2021

Q A
Branch? 5.2
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #39899
License MIT
Doc PR symfony/symfony-docs#...

See #39899. I don't find any solution to convert \INF constant (which is a float value) to an integer.

@@ -29,12 +29,12 @@ final class NoLimiter implements LimiterInterface
{
public function reserve(int $tokens = 1, ?float $maxTime = null): Reservation
{
return new Reservation(time(), new RateLimit(\INF, new \DateTimeImmutable(), true, \INF));
Copy link
Contributor

@OskarStark OskarStark Jan 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not into the code nor the component, but couldn't we use "-1" like for example done in memory_limit setting in PHP instead of a very large number? 🧐

cc @wouterj

Copy link
Contributor Author

@YaFou YaFou Jan 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the only use of the remainingTokens and limit properties is for the developer to know how many requests the user can send. This is not used internally in the RateLimiter component.

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Jan 23, 2021

Thank you @YaFou.

@nicolas-grekas nicolas-grekas merged commit 3fedac0 into symfony:5.2 Jan 23, 2021
5 checks passed
@fabpot fabpot mentioned this pull request Jan 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants