-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpKernel] Fix compatibility with php bridge and already started php sessions #44634
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
0b5f312
to
fc0f2e2
Compare
Hey! I think @mtarld has recently worked with this code. Maybe they can help review this? Cheers! Carsonbot |
Hi! I think the following lines would have to be deleted. It just does not make sense to remove the cookie if the session bags are empty, because that does not mean the session is empty (and used by other application): https://github.com/symfony/symfony/blob/v5.4.0/src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php#L154-L162 |
@devnix this lines can not be removed as they handles the correct handling of a logout when running swoole and roadrunner. I'm currently thinking about check if the PHP bridge is activated and then go with the old behaviour and let PHP handle the session cookie then again. Means that swoole and roadrunner could not be used with that applications correctly but I think that this application don't even use the symfony/runtime so I think that would be fine. |
@alexander-schranz alright, that's what I feared (I didn't make directly a PR because I suspected I was going to miss a fact like that). Speaking from ignorance: maybe the listener could call a method defined by |
@devnix the
As example the logout listener does it by default: symfony/src/Symfony/Component/Security/Http/EventListener/SessionLogoutListener.php Line 29 in d17ae34
So what is missing is to know if a session is invalid or not at current state. But I did avoided to extend the SessionInterface with new methods which are not required currently and so did go with isEmpty. Personaly I think a session which is empty can savely be removed. So I would maybe we should adjust the isEmpty in the PHPBridge to check if there are not other values in the $_SESSION variable beside the empty symfony storage variable. Or find another way to check for invalid session or as said above let PHP handle the session cookie when the php bridge is used.
|
@devnix found that I can check if the session was even changed using the session usage index. Can you check this change with your application? |
f120407
to
8c10721
Compare
I will be able to check it next monday! I have a wild guess: if a session is started by another application, and later a Symfony controller is called without touching the session, will not be deleted because the usage index would be zero? This can even happen with coexisting, separated web applications, not only with legacy applications integrating Symfony |
91df813
to
84e5f4c
Compare
src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php
Outdated
Show resolved
Hide resolved
b0d6278
to
502f6f1
Compare
502f6f1
to
4032e7f
Compare
4032e7f
to
3130dbb
Compare
I will try the patch ASAP, as I don't have access to the repository right now. Thank you so much, @alexander-schranz |
src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php
Outdated
Show resolved
Hide resolved
I know, I'm late to the conversation but I think it would be a good idea to give the person, implementing the session handling a way to control the behavior of creating/deleting the session cookie (as @devnix suggested). In my case we have a centralized login which creates a session (in Redis) and writes the cookie. Now we want to migrate those applications away from the current framework to Symfony, so I implemented a custom authenticator for this session but also wanted to reuse this session in a custom SessionStorage. This worked up until Symfony 5.4 which now kills the externally generated session cookie. My solution now is to have two sessions. One created by our login application and one created by Symfony, using one Redis connection (singleton via DI). |
@johannes85 as discussed in #44634 (comment) there would be better options. But are not possible in a bugfix as a bugfix is not allowed to extend the public API. |
7958a32
to
3ba2678
Compare
3ba2678
to
4052ec1
Compare
Thank you @alexander-schranz. |
Thx all for helping, testing and providing feedback! |
@alexander-schranz could you please have a look at branch 6.0? |
…er-schranz) This PR was submitted for the 6.0 branch but it was squashed and merged into the 5.4 branch instead. Discussion ---------- [HttpKernel] Fix session test cases for symfony | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Related to: #44634 Fix HttpKernel test cases as session are created differently in symfony 6.0. Commits ------- b047a2d [HttpKernel] Fix session test cases for symfony
Fix compatibility to PHPBridge with new session handling.
TODO: