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

[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

Merged
nicolas-grekas merged 1 commit intosymfony:5.4fromalexander-schranz:patch-10
Jan 26, 2022

Conversation

@alexander-schranz
Copy link
Contributor

@alexander-schranzalexander-schranz commentedDec 15, 2021
edited
Loading

QA
Branch?5.4 for bug fixes
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix#44553,Fix#44616
LicenseMIT
Doc PRsymfony/symfony-docs#...

Fix compatibility to PHPBridge with new session handling.

TODO:

  • Test

mbtreetime and BertrandGouny reacted with thumbs up emoji
@carsonbot
Copy link

Hey!

I think@mtarld has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

@alexander-schranzalexander-schranz changed the titleUpdate AbstractSessionListener.phpFix compatbility to php bridge for sessionsDec 16, 2021
@devnix
Copy link

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
Copy link
ContributorAuthor

@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 reacted with thumbs up emoji

@devnix
Copy link

@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 bySessionStorageInterface, so each session storage would know how they have to handle by implementing that method?

@alexander-schranz
Copy link
ContributorAuthor

alexander-schranz commentedDec 23, 2021
edited
Loading

@devnix theisEmpty is currently a way to know ifinvalidate was called:

publicfunctioninvalidate(int$lifetime =null):bool

As example the logout listener does it by default:
$event->getRequest()->getSession()->invalidate();

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 theisEmpty 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 reacted with thumbs up emoji

@carsonbotcarsonbot changed the titleFix compatbility to php bridge for sessions[HttpKernel] Fix compatbility to php bridge for sessionsDec 28, 2021
@alexander-schranz
Copy link
ContributorAuthor

@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?

@alexander-schranzalexander-schranzforce-pushed thepatch-10 branch 2 times, most recently fromf120407 to8c10721CompareDecember 29, 2021 12:23
@alexander-schranzalexander-schranz marked this pull request as ready for reviewDecember 29, 2021 12:43
@devnix
Copy link

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

@alexander-schranzalexander-schranzforce-pushed thepatch-10 branch 3 times, most recently fromb0d6278 to502f6f1CompareDecember 29, 2021 15:42
@alexander-schranz
Copy link
ContributorAuthor

@devnix Thank you for the feedback. Make sense. I tried to create test cases for it and check now also for$_SESSION to avoid these problems with other native sessions variables written before.

/cc@jderusse

devnix reacted with heart emoji

@devnix
Copy link

I will try the patch ASAP, as I don't have access to the repository right now. Thank you so much,@alexander-schranz

alexander-schranz reacted with thumbs up emoji

@johannes85
Copy link
Contributor

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.
Our applications (around 20) are using this already created session.

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.
So, a way for my SessionStorage to tell Symfony: "don't mess with the session cookie" would be nice.

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).
This also doesn't work as intended because of#44616 but is fixed with#44657

@alexander-schranzalexander-schranz changed the title[HttpKernel] Fix compatbility to php bridge for sessions[HttpKernel] Fix compatbility to php native and already started php sessionsJan 20, 2022
@alexander-schranzalexander-schranz changed the title[HttpKernel] Fix compatbility to php native and already started php sessions[HttpKernel] Fix compatbility to php bridge and already started php sessionsJan 20, 2022
@alexander-schranz
Copy link
ContributorAuthor

@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-grekasnicolas-grekas changed the title[HttpKernel] Fix compatbility to php bridge and already started php sessions[HttpKernel] Fix compatibility with php bridge and already started php sessionsJan 26, 2022
@nicolas-grekas
Copy link
Member

Thank you@alexander-schranz.

devnix and Nyholm reacted with hooray emoji

@nicolas-grekasnicolas-grekas merged commit2ab5f29 intosymfony:5.4Jan 26, 2022
@alexander-schranzalexander-schranz deleted the patch-10 branchJanuary 26, 2022 15:29
@alexander-schranz
Copy link
ContributorAuthor

alexander-schranz commentedJan 26, 2022
edited
Loading

Thx all for helping, testing and providing feedback!

devnix, chalasr, arcticlinux, and Nyholm reacted with heart emoji

@nicolas-grekas
Copy link
Member

@alexander-schranz could you please have a look at branch 6.0?
I feel like my merge is wrong there 😬 (tests of HttpKernel are failing).

@alexander-schranz
Copy link
ContributorAuthor

@nicolas-grekas see#45192

nicolas-grekas added a commit that referenced this pull requestJan 27, 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
This was referencedJan 28, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@jderussejderussejderusse approved these changes

@chalasrchalasrchalasr approved these changes

+1 more reviewer

@devnixdevnixdevnix left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

7 participants

@alexander-schranz@carsonbot@devnix@johannes85@nicolas-grekas@jderusse@chalasr

[8]ページ先頭

©2009-2025 Movatter.jp