-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Description
Symfony version(s) affected
6.4.*
Description
enable_lazy_ghost_objects
is causing an issue where
- when loading an entity with and chain of relations marked
EAGER
, entities down the chain are not fully loaded. - Then on
EntityManager->flush()
the unset values are attempted to be written to the database
How to reproduce
Here is a reproducer: https://github.com/craigh/bug-reproducer-1
If you run the reproducer, it better explains the problem than I can do here.
also for reference: https://stackoverflow.com/questions/78267848/proxy-object-tries-to-write-unset-values-to-database?noredirect=1#comment138011312_78267848
I have an EntityA that has EAGER loaded ManyToOne relation to EntityB. EntityB also has EAGER loaded ManyToOne relation to EntityC.
I have a simple controller to edit EntityA. It loads EntityA in the action arg, e.g. public function edit(EntityA $a): Response {}
.
In the controller I make a few changes to $a
and then flush the entity manager. On flush I get the error
SQLSTATE[23000]: Integrity constraint violation: 1048 Column ‘first_name’ cannot be null
It appears that the proxy is not loading the relations and then on flush, attempting to write the non-loaded values back on the entity.
Possible Solution
No response
Additional Context
No response