mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-3676: Entity executing UPDATE on Collection elements with PostLoad callback when cloning #4516
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Apr 8, 2015).
Originally assigned to: @Ocramius on GitHub.
Jira issue originally created by user webdevilopers:
My
Branchentity has a collection ofContracts.https://gist.github.com/webdevilopers/65716f36ac2249e5e899#file-branch-php
A
Contracthas a PostLoad event which is converting a legacy yaml database field to a readable format.https://gist.github.com/webdevilopers/65716f36ac2249e5e899#file-contract-php
When cloning a Branch the database executes a single INSERT for the new branch successfully.
It does NOT persist any collection which is the expected behaviour since I guess relations have to be handled inside the **clone method separately.
But after the INSERT the database also fires an UPDATE on each Contract (currently *3000* related rows in database) updating the column that was converted inside the PostLoad event.
I think calling the PostLoad is correct. But why is there an additional UPDATE called?
https://gist.github.com/webdevilopers/65716f36ac2249e5e899#file-branchcontroller-php
Maybe the flush recognizes changes in the original Branch entity and its Contract collection?
When I add a clear to my __clone method I get _9* instead of 3000 _UPDATE* queries:
These 9 remaing UPDATE are additionally fired by another callback:
In summary:
At the bottom line the _clone method causes *9 UPDATE queries for Pre* and 3000 (number of related database rows) for _PostLoad*.
@doctrinebot commented on GitHub (Apr 8, 2015):
Comment created by @ocramius:
Resolving as invalid: please provide a small reproducible example that is not specific to your codebase.
As it stands, this seems more like a debugging request.
@doctrinebot commented on GitHub (Apr 8, 2015):
Issue was closed with resolution "Invalid"
@doctrinebot commented on GitHub (Apr 8, 2015):
Comment created by webdevilopers:
Sure Marco, I will add some fixtures to my example to make it reproducable if that is enough for debugging?