This gist should help you if you are getting the following exception in your TYPO3 website Symfony\Component\RateLimiter\Policy\SlidingWindow::getExpirationTime(): Return value must be of type int, float returned
.
The following requirements must be set to be affected:
- TYPO3 11.5
- PHP 8.1. Read more about the relevant changes at php.watch
- Package
symfony/rate-limiter
in version 5.4.7 (released 2022-04-02) - Deprecations notices are converted into exceptions
The bug in the symfony component has been discovered on 2022-04-03 and fixed on the same day. Thanks to everybody involved ❤!
To fix the issue the following options are possible:
1. Downgrade the package
Use composer req symfony/rate-limiter:5.4.3
to downgrade to the version before.
2. Add current version as conflict
This method got the advantage that you will get automatically new versions once released.
"conflict": {
"symfony/rate-limiter": "5.4.7"
}
3. Patch the package
Use the aweseome package cweagans/composer-patches
and a patch file like
Index: Policy/SlidingWindow.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/Policy/SlidingWindow.php b/Policy/SlidingWindow.php
--- a/Policy/SlidingWindow.php
+++ b/Policy/SlidingWindow.php (date 1648547298000)
@@ -76,7 +76,7 @@
*/
public function getExpirationTime(): int
{
- return $this->windowEndAt + $this->intervalInSeconds - microtime(true);
+ return (int)($this->windowEndAt + $this->intervalInSeconds - microtime(true));
}
public function isExpired(): bool
- Open source is great! The bug has been identified by @sbuerk and @georgringer on a Sunday morning and the patch has been merged by @nicolas-grekas only a couple hours later!
- Automated tests work! The automated daily tests of TYPO3 discovered the code. Tests work!
- Always adopt your code to latest standards, use e.g. return types. It helps not only the IDE but if the code fails, you will be able to spot it
Thanks also to Studio Mitte, my employer who is sponsoring the work time