mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Lost Update when using Deferred Explicit change tracking, Remove followed by Persist. #6518
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 @skurfuerst on GitHub (Aug 7, 2020).
... That's hard to describe, I'll try nevertheless :-)
Background
$entity.How to reproduce
$entityManager->remove($entity);$entity->setFoo('bar');$entityManager->persist($entity);$entityManager->flush();Root Cause Analysis:
$entityManager->remove($entity);UnitOfWork::doRemove(), where the entity is marked withUnitOfWork::STATE_REMOVED.$entity->setFoo('bar');$entityManager->persist($entity);UnitOfWork::doPersist().UnitOfWork::STATE_MANAGEDagain (it was marked as removed beforehand).UnitOfWork::scheduleForDirtyCheck(), which it would call if the entity was alreadyin
STATE_MANAGED. We rely on thisscheduleForDirtyCheckto be called, because we use DEFERRED_EXPLICIT as change tracking policy.$entityManager->flush();Suggested fix:
in
UnitOfWork::doPersistNote: this issue appeared as part of https://github.com/neos/neos-development-collection/pull/3015
Thanks for your great work :)
Sebastian
@beberlei commented on GitHub (Sep 13, 2020):
@skurfuerst Valid report, please make it a pull request against the 2.7 branch.