mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-2703: UnitOfWork should not compute the change set on updated but not-persisted entities. #3384
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 (Sep 24, 2013).
Originally assigned to: @guilhermeblanco on GitHub.
Jira issue originally created by user shiroyuki:
Problem:
UnitOfWork computes the change set on updated but not-persisted entities.
How to reproduce:
Expectation:
Any changes on the entity which is not persisted must not be stored in the database.
Actual Result:
The changes are saved.
Use the example:
app/console sandbox:case0to recreate the bug.Note:
I traced the bug down to
computeChangeSetand it seems that even though the entity is not scheduled for dirty checks, the unit of work still computes the change set of the problematic entity. From the provided example, the node named "Node 2" should not be updated to "B" when the CaseZero command is executed.@doctrinebot commented on GitHub (Sep 24, 2013):
Comment created by @ocramius:
[~shiroyuki] we are not going to checkout your project for this. Please make a small example that uses ONLY the ORM, with no other involved frameworks.
You should be able to do that in a single php script that includes:
we can then convert that into a unit test once it has been verified.
@doctrinebot commented on GitHub (Sep 24, 2013):
Comment created by @guilhermeblanco:
This should be related to change tracking policy.
Doctrine uses IMPLICIT change tracking policy by default, applying an algorithm called persist-by-reachability.
To fix your issue, you need to modify your change tracking to DEFERRED_EXPLICIT or NOTIFY.
Here is a more detailed explanation:
So the change you need to do is: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/change-tracking-policies.html
@doctrinebot commented on GitHub (Sep 24, 2013):
Comment created by @guilhermeblanco:
It's an issue of misunderstanding change tracking policies.
@doctrinebot commented on GitHub (Sep 24, 2013):
Issue was closed with resolution "Invalid"
@doctrinebot commented on GitHub (Sep 24, 2013):
Comment created by shiroyuki:
Thank you. :D