Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
0b5f312 tofc0f2e2Comparecarsonbot commentedDec 16, 2021
Hey! I think@mtarld has recently worked with this code. Maybe they can help review this? Cheers! Carsonbot |
devnix commentedDec 23, 2021
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 |
alexander-schranz commentedDec 23, 2021
@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. |
devnix commentedDec 23, 2021
@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 |
alexander-schranz commentedDec 23, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@devnix the
As example the logout listener does it by default: symfony/src/Symfony/Component/Security/Http/EventListener/SessionLogoutListener.php Line 29 ind17ae34
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. |
alexander-schranz commentedDec 29, 2021
@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 to8c10721Comparedevnix commentedDec 29, 2021
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 to84e5f4cComparesrc/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
b0d6278 to502f6f1Comparealexander-schranz commentedDec 29, 2021
502f6f1 to4032e7fCompare4032e7f to3130dbbComparedevnix commentedDec 29, 2021
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 OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/HttpKernel/EventListener/AbstractSessionListener.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
johannes85 commentedJan 17, 2022
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). |
alexander-schranz commentedJan 20, 2022
@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. |
nicolas-grekas commentedJan 26, 2022
Thank you@alexander-schranz. |
alexander-schranz commentedJan 26, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Thx all for helping, testing and providing feedback! |
nicolas-grekas commentedJan 26, 2022
@alexander-schranz could you please have a look at branch 6.0? |
alexander-schranz commentedJan 26, 2022
…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:#44634Fix HttpKernel test cases as session are created differently in symfony 6.0.Commits-------b047a2d [HttpKernel] Fix session test cases for symfony
Uh oh!
There was an error while loading.Please reload this page.
Fix compatibility to PHPBridge with new session handling.
TODO: