Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add BC layer to handle old objects already present in cache#45876

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nicolas-grekas merged 1 commit intosymfony:5.4fromSeldaek:patch-21
Mar 29, 2022

Conversation

@Seldaek
Copy link
Member

@SeldaekSeldaek commentedMar 29, 2022
edited
Loading

QA
Branch?5.4
Bug fix?yes
New feature?no
Deprecations?no
TicketsRefs#44996
LicenseMIT
Doc PRsymfony/symfony-docs#...

When reloading an old RateLimiter instance from cache with the new code I did get an exception because windowEndAt was a string and getHitCount does windowEndAt - intervalInSeconds, and string - int fails.

The reason is the new code assigns the id to windowEndAt via:

        $pack = key($data);        $this->windowEndAt = $data[$pack];

I dumped $this and $data in __unserialize just FYI and you get this:

object(Symfony\Component\RateLimiter\Policy\SlidingWindow)[959]  private 'id' => null  private 'hitCount' => int 0  private 'hitCountForLastWindow' => int 0  private 'intervalInSeconds' => null  private 'windowEndAt' => null
array (size=5)  '�Symfony\Component\RateLimiter\Policy\SlidingWindow�id' => string 'login_per_ip-127.0.0.1' (length=22)  '�Symfony\Component\RateLimiter\Policy\SlidingWindow�hitCount' => int 2  '�Symfony\Component\RateLimiter\Policy\SlidingWindow�intervalInSeconds' => int 60  '�Symfony\Component\RateLimiter\Policy\SlidingWindow�hitCountForLastWindow' => int 0  '�Symfony\Component\RateLimiter\Policy\SlidingWindow�windowEndAt' => float 1648544909.4762

I only tested the code in real conditions for SlidingWindow, but I do believe/hope the same applies for the other two policies.

$this->tokens =$data[1];
$this->timer =$data[2];
$this->burstSize =$data[3];
$this->stringRate =$data[4];

Choose a reason for hiding this comment

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

actualy let's remove this one, remove wakeup and move its logic here

Choose a reason for hiding this comment

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

argh no! that'd break compat with php < 7.4

Choose a reason for hiding this comment

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

$this->rate = Rate::fromString($data[4]); then

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Oh yeah missed that the stringRate prop does not exist :)

@nicolas-grekas
Copy link
Member

Thank you@Seldaek.

@nicolas-grekasnicolas-grekas merged commit45d0023 intosymfony:5.4Mar 29, 2022
@SeldaekSeldaek deleted the patch-21 branchMarch 29, 2022 10:10
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@NyholmNyholmNyholm left review comments

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

4 participants

@Seldaek@nicolas-grekas@Nyholm@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp