-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] Regression in using the session in kernel.terminate #40778
New issue
Have a question about this project?< 8000 /strong> 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
Comments
The If I'm not wrong, there is no BC-Break here: people that use the session service will still get the session from the container (with a deprecation now). This is "just" about people migrating from I'm 👎 for adding the lat previous request' session in the requestStack. This would defeat the the point of removing the state from services. People willing to fixing the deprecation should stop using state from service, including session, including session from an empty RequestStack. |
@jderusse then we should fix this in the Line 89 in 9092d5b
We're not using the session directly in our listeners, the token storage is. If I understand you correctly, you propose to fix the usage tracking token storage to not use the session if there is no main requests (anymore)? |
…utside the request-response cycle (wouterj) This PR was merged into the 5.3-dev branch. Discussion ---------- [Security] Deprecate using UsageTrackingTokenStorage outside the request-response cycle | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | yes | New feature? | no | Deprecations? | yes | Tickets | Fix #40778 | License | MIT | Doc PR | - Currently, you get an "There is currently no session available" exception when using the `security.token_storage` service outside the main request-response cycle (e.g. in a `kernel.terminate` listener). This PR deprecates such usage and requires developers to update their definitions to explicitly use `security.untracked_token_storage` instead. A different solution would be to silently disable tracking in these cases, but I think that might create some unnecessary technical debt. Commits ------- 7452476 [Security] Fix UsageTrackingTokenStorage outside the request cycle
Symfony version(s) affected: 5.x
Description
I was testing one of our main apps in 5.x and discovered a regression with the new session logic when using the token storage, causing "There is currently no session available." (related change: #38616)
We use a listener on
kernel.terminate
to log some information (including the current username). However,RequestStack::getSession()
only works when there is a main request (which is not the case in thekernel.terminate
event). Before 5.3, thesession
service was usable outside a main request.The fix on our side was quite easy: use the
security.untracked_token_storage
service. Yet, I do believe there should be no hard breaksHow to reproduce
kernel.terminate
Possible Solution
Maybe store the main
$request->getSession()
(inRequestStack::push()
) in a variable and use it when there is no main request anymore? (and immediately deprecate this behavior) This way, there is no hard break between the version upgrade and there is a way to direct the user into the right debugging path.The text was updated successfully, but these errors were encountered: