mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
[PR #10884] Fix broken changeset computation for entities loaded through fetch=EAGER + using inheritance #12676
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?
Original Pull Request: https://github.com/doctrine/orm/pull/10884
State: closed
Merged: Yes
#10880 reports a case where the changes from #10785 cause entity updates to be missed.
Upon closer inspection, this change seems to be causing it:
https://github.com/doctrine/orm/pull/10785/files#diff-55a900494fc8033ab498c53929716caf0aa39d6bdd7058e7d256787a24412ee4L2990-L3003
The code was changed to use
registerManaged()instead, which basically does the same things, but (since #10785) also includes an additional check against duplicate entity instances.But, one detail slipped through tests and reviews:
registerManaged()also updates\Doctrine\ORM\UnitOfWork::$originalEntityData, which is used to compute entity changesets. An empty array[]was passed for $data here.This will make the changeset computation assume that a partial object was loaded and effectively ignore all field updates here:
a616914887/lib/Doctrine/ORM/UnitOfWork.php (L762-L764)I think that, effectively, it is sufficient to call
registerManaged()only in the two cases where a proxy was created.Calling
registerManaged()with[]as data for a proxy object is consistent with e. g.\Doctrine\ORM\EntityManager::getReference().In the case that a full entity has to be loaded, we need not call
registerManaged()at all, since that will already happen insideEntityManager::find()(or, more specifically,UnitOfWork::createEntity()called inside it).Note that the test case has to make some provisions so that we actually reach this case:
fetch="EAGER"on a to-one association