Fix cloning entities when using lazy-ghost proxies#10819
Conversation
| */ | ||
| private $identifierFlattener; | ||
|
|
||
| /** @var ProxyDefinition[] */ |
There was a problem hiding this comment.
this looks like array<class-string, ProxyDefinition>
There was a problem hiding this comment.
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