-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[RFC] Add a DoctrineOrmSessionHandler
#58257
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
Comments
Managing the session with the ORM seems like a bad idea: as saving the session is managed by the PHP session system, it means that this custom handler would be the one triggering the flush. And this would be a total no-go if it uses the same EntityManager instance than your project code (having all your entities being flushed at the end of each request when the PHP session is saved will be a nightmare to manage, for instance if you use forms bound directly on entities by avoiding to flush entities in case of invalid form submission, as you would not be able to avoid the flush anymore).
|
I fixed my previous message regarding the format of the PHP data. At the level of the handler, the session data is a string (as it has already been serialized), not an array. |
Thanks for the complete feedback @stof. What do you recommend when advanced modifications need to be made to the database (apart from renaming columns, which is already possible)? For instance:
I guess we create a class overriding the Many thanks in advance |
@Crovitche-1623 using a datetime column at the database level can be done with a custom handler even if it does not use the ORM (not sure you can extend the PdoSessionHandler or if you would have to start from scratch if you want that, as it will probably require changing the way the time column is managed in queries) Regarding the session data, storing it as json would mean that the handler itself has to unserialize the data and then convert it on JSON when writing (and doing the opposite on reading). But even that does not require using an ORM at all. Not sure it is worth the cost. And for the |
How about a session handler based on Doctrine DBAL? |
Hi 👋🏻 Regarding the idea from @derrabus, mind if I ask what's the use case of using a DBAL handler? For now, we can store the session using the PDO handler (doc), the PDO one seems to support a "Doctrine-like" DSN, what will be the pros/cons of using DBAL? I was thinking about easing the migration path between storage engines but I might miss something, any extra thoughts? 🤔 Thanks 🙂 |
In my analysis and tests, here are the advantages and disadvantages I found when using DBAL : Advantages:
Disadvantages:
And the problem I encountered:
I haven't managed to find the problem yet. |
Thanks for the feedback, I'm currently working on a POC about this one using the idea brought by @derrabus, I'll post the progress here 🙂 |
Thank you for this suggestion. |
Friendly ping? Should this still be open? I will close if I don't hear anything. |
Hey, I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen! |
Description
I think it could be an interesting feature to have a
DoctrineOrmSessionHandler
in addition of thePdoSessionHandler
.This would allow :
Then perhaps we could then use an interface with methods concerning the results expected on the doctrine entity ?
WDYT ?
Example
No response
The text was updated successfully, but these errors were encountered: