10000 [RateLimiter] Only use old windowEndAt if it is still current · symfony/symfony@1073a52 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1073a52

Browse files
committed
[RateLimiter] Only use old windowEndAt if it is still current
1 parent 604a484 commit 1073a52

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Symfony/Component/RateLimiter/Policy/SlidingWindow.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ public static function createFromPreviousWindow(self $window, int $intervalInSec
6464
{
6565
$new = new self($window->id, $intervalInSeconds);
6666
$new->hitCountForLastWindow = $window->hitCount;
67-
$new->windowEndAt = $window->windowEndAt + $intervalInSeconds;
67+
$windowEndAt = $window->windowEndAt + $intervalInSeconds;
68+
69+
if (time() < $windowEndAt) {
70+
$new->windowEndAt = $windowEndAt;
71+
}
6872

6973
return $new;
7074
}

0 commit comments

Comments
 (0)
0