[RateLimiter] Resolve crash on near-round timestamps#44941
Merged
fabpot merged 1 commit intosymfony:5.4from Jan 24, 2022
Merged
[RateLimiter] Resolve crash on near-round timestamps#44941fabpot merged 1 commit intosymfony:5.4from
fabpot merged 1 commit intosymfony:5.4from
Conversation
GromNaN
approved these changes
Jan 12, 2022
Member
GromNaN
left a comment
There was a problem hiding this comment.
I confirm this behavior of DateTimeImmutable::createFromFormat and the resulting bug.
https://3v4l.org/37Qov
src/Symfony/Component/RateLimiter/Tests/Policy/SlidingWindowTest.php
Outdated
Show resolved
Hide resolved
26640cc to
4965952
Compare
fabpot
approved these changes
Jan 24, 2022
Member
|
Thank you @xesxen. |
Contributor
|
Is there any chance of getting a release for this? This explains why we are randomly seeing errors about |
Member
|
@nesl247, new releases are coming in the next few days. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Occasionally timestamps will be fully round (eg. 1234567890.000000) or close to it (eg. 1234567890.000031).
When converting those specific float timestamps to string in SlidingWindow (due to
DateTimeImmutable::createFromFormat), the number is formatted by PHP without any digits. This causes the resulting value of SlidingWindow::getRetryAfter() to be violated with the boolean valuefalse.This patch formats the float to include the decimal digits.