-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fix cloning entities when using lazy-ghost proxies #10819
Conversation
@@ -98,6 +86,9 @@ public function __serialize(): array | |||
*/ | |||
private $identifierFlattener; | |||
|
|||
/** @var ProxyDefinition[] */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like array<class-string, ProxyDefinition>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I borrowed from the parent class ;)
b6d9ce6
to
a03ccfe
Compare
a03ccfe
to
eee87c3
Compare
All green 🍏 |
Thanks @nicolas-grekas ! |
Can you guys provide an example when/how it is useful to clone entities and what the semantics of this operation are? Does the new (cloned) entity let go of its ID? Should the EntityManager know about it? Is it in |
@mpdude the cloned object will not be managed by the entity manager |
When the entity that is cloned is an uninitialized proxy at that point in time, what happens when I call a method on the clone that triggers loading? |
Coming from #3037 and #10785 where one source of "weird" problems is corruption of internal UoW state-tracking fields. This may be caused when using proxies directly created by the ProxyFactory. My concern is that cloning a proxy object might be no different: Suddenly there are two objects claiming to proxy the same entity. But, "there can be only one", only the proxy object the UoW knows about should be initialized and is the sole object representing that entity. |
I stumbled upon this while investigating an issue that seems to be related to this fix, and your suspicion seems to be confirmed. Since doctrine/orm 2.15.4 I encounter the following problem:
Up until now, everything is as expected. However, once I read some data from |
Please open a dedicated issue with a reproducer. Commenting on closed issues/PRs isn't tracked. |
Fixes #10817
Replaces #10818
Replaces symfony/symfony#50899