1
0
mirror of synced 2025-01-30 20:11:49 +03:00

[DDC-2775] Bugfix

This commit is contained in:
Matthieu Napoli 2013-11-04 12:42:23 +01:00
parent 8bd54be4ec
commit e018bb83f0

View File

@ -2230,6 +2230,10 @@ class UnitOfWork implements PropertyChangedListener
function ($assoc) { return $assoc['isCascadeRemove']; } function ($assoc) { return $assoc['isCascadeRemove']; }
); );
$entitiesToCascade = array();
// We need to load all related entities beforehand so that lazy collection loading doesn't
// reload entities after they have been removed (bug DDC-2775)
foreach ($associationMappings as $assoc) { foreach ($associationMappings as $assoc) {
if ($entity instanceof Proxy && !$entity->__isInitialized__) { if ($entity instanceof Proxy && !$entity->__isInitialized__) {
$entity->__load(); $entity->__load();
@ -2242,18 +2246,22 @@ class UnitOfWork implements PropertyChangedListener
case (is_array($relatedEntities)): case (is_array($relatedEntities)):
// If its a PersistentCollection initialization is intended! No unwrap! // If its a PersistentCollection initialization is intended! No unwrap!
foreach ($relatedEntities as $relatedEntity) { foreach ($relatedEntities as $relatedEntity) {
$this->doRemove($relatedEntity, $visited); $entitiesToCascade[] = $relatedEntity;
} }
break; break;
case ($relatedEntities !== null): case ($relatedEntities !== null):
$this->doRemove($relatedEntities, $visited); $entitiesToCascade[] = $relatedEntities;
break; break;
default: default:
// Do nothing // Do nothing
} }
} }
foreach ($entitiesToCascade as $relatedEntity) {
$this->doRemove($relatedEntity, $visited);
}
} }
/** /**