You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When remove en entity, before flush, if we fetch the entity again it will return a new object breaking the "unique instance pooling". Checking the state of this entity will be managed, checking directly if the entity is schedule for removing will return false.
I presume it will be consider a breaking change but fixing this seem to result in the expected behaviour.
The issue is related to the code removing the object from the identity map when the UnitOfWork::remove is call (via a chain of internal call).
Current behavior
Fetching an an entity schedule for removal will return a new object instance.
How to reproduce
// This is a simplified version of a more complex flow
Bug Report
Summary
When remove en entity, before flush, if we fetch the entity again it will return a new object breaking the "unique instance pooling". Checking the state of this entity will be managed, checking directly if the entity is schedule for removing will return false.
I presume it will be consider a breaking change but fixing this seem to result in the expected behaviour.
The issue is related to the code removing the object from the identity map when the UnitOfWork::remove is call (via a chain of internal call).
Current behavior
Fetching an an entity schedule for removal will return a new object instance.
How to reproduce
// This is a simplified version of a more complex flow
$id = 1;
$object1 = $em->find('ObjectClass', $id);
$em->remove($object1);
$object2 = $em->find('ObjectClass', $id);
echo $em->getUniqueOfWork()->isScheduledForDelete($object1) ? 'yes' : 'no'; // yes
echo $em->getUniqueOfWork()->isScheduledForDelete($object2) ? 'yes' : 'no'; // no
echo $object1 === $object2 ? 'yes' : 'no'; // no
echo $object1->getId() === $object2->getId() ? 'yes' : 'no'; // yes
Expected behavior
$id = 1;
$object1 = $em->find('ObjectClass', $id);
$entityManager->remove($object1);
$object2 = $em->find('ObjectClass', $id);
echo $em->getUniqueOfWork()->isScheduledForDelete($object1) ? 'yes' : 'no'; // yes
echo $em->getUniqueOfWork()->isScheduledForDelete($object2) ? 'yes' : 'no'; // yes
echo $object1 === $object2 ? 'yes' : 'no'; // yes
echo $object1->getId() === $object2->getId() ? 'yes' : 'no'; // yes
The text was updated successfully, but these errors were encountered: