-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] Make SessionHandlerProxy
implement SessionIdInterface
#50626
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
dc84dfb
to
9277bc2
Compare
src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php
Show resolved
Hide resolved
9277bc2
to
06b6e73
Compare
Does this suppose to help setting the a custom session id using |
I think all decorators should implement this, isn't it? |
06b6e73
to
615fd49
Compare
Woops missed your comment.
I guess they could 🤔 else you’re required to put your |
Eeer after reading https://symfony.com/doc/current/session.html#session-proxies I wonder if this PR makes sense as you’re supposed to extend |
Okay, just tried to do that and I got a |
I'm a bit lost between the handler, the proxy, etc. I'll let you investigate if you don't mind :) |
I’m still lost but I have some leads: session proxies purpose was originally to ease the migration from PHP 5.3 where The That’s why I thought you were supposed to decorate |
615fd49
to
2aef7e6
Compare
Closing, since there already is a way to configure a |
I have been struggling for most of the day trying to figure out why the create_sid() method was never being called from my custom session handler. I finally found it was because even though I am specifying a class that implements I think it would be beneficial to reconsider implementing this. @MatTheCat Is right that you can decorate the If it is decided that it's best not to implement this, we may want to consider deprecating passing a service that does not extend |
This is another big reason that this PR should be reconsidered. It's awkward to work around the current implementation due to the circular dependency @MatTheCat mentioned above. You have to either have two classes, one for the majority of the custom handler implementation that implements framework:
session:
enabled: true
storage_factory_id: session.storage.factory.native
handler_id: App\SessionHandlerProxy
services:
App\SessionHandlerProxy:
arguments:
$handler: App\SessionHandler You could implement all the handler functionality to the |
Hey @jdevinemt 👋 Glad to see you concerned, but closed PRs don't usually generate traction; opening an issue may be better. |
Thanks @MatTheCat. I had a feeling that might be the case. I just finished my implementation to work around this restriction in my current project. I'm working through writing tests to cover my handler and handler proxy services. Once I'm done with that I'll open a new issue and create a PR if I can figure out the best way to implement this interface. |
Supersedes #47071
It is currently not easy to provide its own session ids because even if your handler implements
SessionIdInterface
, it will be wrapped in aSessionHandlerProxy
which does not, so yourcreate_sid
method won’t be called.