Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Symfony\Component\RateLimiter\Policy\SlidingWindow::getExpirationTime(): Return value must be of type int, float returned #45924

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

Closed
georgringer opened this issue Apr 3, 2022 · 9 comments

Comments

@georgringer
Copy link
Contributor

Symfony version(s) affected

5.4.7

Description

With the commit of symfony/rate-limiter@4716500 the method getExpirationTime changed and now a float is returned but the return type is set to int which produces an exception

How to reproduce

No out of box code available but using microtime(true) returns a float

Possible Solution

type cast like

return (int)($this->windowEndAt + $this->intervalInSeconds - microtime(true));

Additional Context

No response

@nicolas-grekas
Copy link
Member

Cast is needed indeed. Can you please send a PR to fix this, branch 5.4, with a test case?

@georgringer
Copy link
Contributor Author

@nicolas-grekas PR added

nicolas-grekas added a commit that referenced this issue Apr 3, 2022
…Time (georgringer)

This PR was squashed before being merged into the 5.4 branch.

Discussion
----------

[RateLimiter] Add typecase to SlidingWindow::getExpirationTime

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #45924
| License       | MIT

Commits
-------

de8a2c2 [RateLimiter] Add typecase to SlidingWindow::getExpirationTime
@georgringer
Copy link
Contributor Author

@nicolas-grekas thanks for the merge! Can you give details for a new release? I am asking because without updating typo3 projects fail hard currently

@nicolas-grekas
Copy link
Member

Releases happen every month, so end of April now... But this shouldn't be a fatal error. On my side, I only get a deprecation.

@georgringer
Copy link
Contributor Author

georgringer commented Apr 3, 2022

that is kind of a pitty. in TYPO3 core we are getting exceptions with PHP8.1, e.g. in the nightly builds https://git.typo3.org/typo3/CI/cms/-/jobs/1174281

@fabpot
Copy link
Member

fabpot commented Apr 3, 2022

We can probably do some hotfix releases in the next couple of days. Let's see first if we have some other emergency fixes.

@nicolas-grekas
Copy link
Member

I'm not sure this need an emergency fix: from what I understand, the CI is turning a deprecation into an error. That's the issue to me and the CI should be fixed to handle deprecations more seamlessly. There's always also the possibility of locking the version to the previous version while waiting for the next release.

@sbuerk
Copy link

sbuerk commented Apr 3, 2022

Granted, in this case it's not a real bug .. but could have been. For example here, the code changed and now the value may be float. If the float would been needed as return value, information would have been lost - and thus a bug. Even if reported as deprecation. Here new code has been added, but with the intention that the float fraction part is not relevant and int is the return value to go.

That's one of the reason TYPO3 raised deprecation to fail hard in the pipeline. But that's up to each project itself.

We would have preferred a quicker release, but absolutly understandable why the decision is here another. At least from my side. Nothing to discuss here, maybe there is another emergency fix pressing for an earlier release which includes this fix then.

Avoid deprecation and eventually related bugs with it as early and hard as possible. Internally and for reporting to 3rd party packages. Given, if TYPO3 still would have had relaxed pipelines this would not have been detected and reported so quickly.

Having a red pipeline is a issue on our side (TYPO3), and we will find a way to deal with it. Skipping these tests for the meanwhile until the relase or something like that. Relaxing it is no option - we have found and fixed to much with E_ALL and deprecation as exception to step back here.

However - big thanks for the quick response, review and merge on a Sunday in freetime, which ensures this will be included in the next release. I think we will find a way how to deal with this in the TYPO3 core until the release.

@georgringer
Copy link
Contributor Author

Thanks @sbuerk for finding the right words and all others involved!

reviewtypo3org pushed a commit to TYPO3/typo3 that referenced this issue Apr 4, 2022
symfony/rate-limiter:5.4.7 has a bug [1] leading to
E_DEPRECATED warnings in our functional rate limiting
tests. This is mostly test related so it does not
make much sense to set this version as conflict.

We'll comment two tests while waiting for a patch
level release 5.4.8.

[1] symfony/symfony#45924

Releases: main, 11.5
Resolves: #97298
Change-Id: Ifb80a631830bb7b50fdc7c9d58d28e0dbf208ad1
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74170
Tested-by: Stefan Bürk <[email protected]>
Tested-by: core-ci <[email protected]>
Tested-by: Oliver Bartsch <[email protected]>
Tested-by: Georg Ringer <[email protected]>
Reviewed-by: Stefan Bürk <[email protected]>
Reviewed-by: Oliver Bartsch <[email protected]>
Reviewed-by: Georg Ringer <[email protected]>
TYPO3IncTeam pushed a commit to TYPO3-CMS/core that referenced this issue Apr 4, 2022
symfony/rate-limiter:5.4.7 has a bug [1] leading to
E_DEPRECATED warnings in our functional rate limiting
tests. This is mostly test related so it does not
make much sense to set this version as conflict.

We'll comment two tests while waiting for a patch
level release 5.4.8.

[1] symfony/symfony#45924

Releases: main, 11.5
Resolves: #97298
Change-Id: Ifb80a631830bb7b50fdc7c9d58d28e0dbf208ad1
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74170
Tested-by: Stefan Bürk <[email protected]>
Tested-by: core-ci <[email protected]>
Tested-by: Oliver Bartsch <[email protected]>
Tested-by: Georg Ringer <[email protected]>
Reviewed-by: Stefan Bürk <[email protected]>
Reviewed-by: Oliver Bartsch <[email protected]>
Reviewed-by: Georg Ringer <[email protected]>
reviewtypo3org pushed a commit to TYPO3/typo3 that referenced this issue Apr 4, 2022
symfony/rate-limiter:5.4.7 has a bug [1] leading to
E_DEPRECATED warnings in our functional rate limiting
tests. This is mostly test related so it does not
make much sense to set this version as conflict.

We'll comment two tests while waiting for a patch
level release 5.4.8.

[1] symfony/symfony#45924

Releases: main, 11.5
Resolves: #97298
Change-Id: Ifb80a631830bb7b50fdc7c9d58d28e0dbf208ad1
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74138
Tested-by: core-ci <[email protected]>
Tested-by: Georg Ringer <[email protected]>
Reviewed-by: Georg Ringer <[email protected]>
TYPO3IncTeam pushed a commit to TYPO3-CMS/core that referenced this issue Apr 4, 2022
symfony/rate-limiter:5.4.7 has a bug [1] leading to
E_DEPRECATED warnings in our functional rate limiting
tests. This is mostly test related so it does not
make much sense to set this version as conflict.

We'll comment two tests while waiting for a patch
level release 5.4.8.

[1] symfony/symfony#45924

Releases: main, 11.5
Resolves: #97298
Change-Id: Ifb80a631830bb7b50fdc7c9d58d28e0dbf208ad1
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74138
Tested-by: core-ci <[email protected]>
Tested-by: Georg Ringer <[email protected]>
Reviewed-by: Georg Ringer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants