-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Response] getMaxAge()
returns non-negative integer
#48880
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
Conversation
Hey! Thanks for your PR. You are targeting branch "6.3" but it seems your PR description refers to branch "5.4". Cheers! Carsonbot |
$response->headers->set('Expires', -1); | ||
$this->assertLessThanOrEqual(time() - 2 * 86400, $response->getExpires()->format('U')); | ||
$this->assertSame(0, $response->getMaxAge()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test was for getMaxAge()
however in this case it was testing getExpires()
, which seemed wrong.
There is a failing test for It seems to me that a negative TTL is illogical the same way as a negative |
I supposeI would expect |
Agreed, I've changed the |
src/Symfony/Component/HttpKernel/Tests/EventListener/SessionListenerTest.php
Outdated
Show resolved
Hide resolved
Apologies for the review requests, they were done automatically when I made a rebase mistake. The tests for 8.0 and 8.1 fail, but I am having trouble finding out why. I did a composer install inside a docker container and ran the tests there but then I got a different (unrelated) failing test, while the test that is failing in the build did pass there. Any help here would be appreciated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All failing tests seem unrelated to your changes.
Went too fast. This one seems relate (on low-deps):
|
getMaxAge()
returns non-negative integer
I noticed that too, the only way that should be possible is if the
This gave the following problem:
To get around this I temporarily removed the custom repo path for the runtime component (it is not related in any way to this change). Then it did install the dependencies, and the test runs without issues:
So I'm not sure what to do now? |
@fabpot could you point me in the right direction to move this PR forward? |
Wohoo. Thanks @pkruithof I hit the very same bug (not so easy to find ; especially if you have a reverse proxy in front of it (HTTP/1.0 vs HTTP/1.1). Your bug report is excellent. I tested your PR and it fixes my issue too. Note: in our case, with nginx as a proxy, the max age was negative |
@pkruithof The problem is that your change impacts 2 components (which are independent). To fix the issue, you should bump the minimum version of HttpFoundation in the HttpKernel composer.json file. Right now, it's |
Thank you @pkruithof. |
The
max-age
directive should be a non-negative integer, see MDN:In case the value is negative, it's encouraged to be treated as 0:
In my case, it lead to a response that was
private,no-cache
but with anExpires
header set in the future. Not every browser handled this inconsistency the same, which eventually led to authentication issues (see linked comment for a more elaborate explanation).