mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-182: Changing entity in preUpdate hook tramples existing changes #225
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 (Nov 28, 2009).
Jira issue originally created by user amirabiri:
If the object is changed during the pre-update callback, this causes the previous changes to be discarded.
Steps to reproduce:
Result is that changes to property A are discarded.
The reason for that is that at the end of Doctrine\ORM\UnitOfWork::_computeEntityChanges() these two statements appear:
However at the end of Doctrine\ORM\UnitOfWork::computeSingleEntityChangeSet(), which is called after the pre-update callbacks are called, the same thing happens:
Because the original data is recorded as equal to the state of the object after the first call to _computeEntityChanges(), the call to computeSingleEntityChangeSet() does not detect the original set of changes, it only detects the changes made in the pre-update hooks. But at the same time, both methods completely overwrite the changeset buffer for the entity rather than merge it. The result is that the first changeset is completely discarded.