1
0
mirror of synced 2025-01-29 19:41:45 +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']; }
);
$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) {
if ($entity instanceof Proxy && !$entity->__isInitialized__) {
$entity->__load();
@ -2242,18 +2246,22 @@ class UnitOfWork implements PropertyChangedListener
case (is_array($relatedEntities)):
// If its a PersistentCollection initialization is intended! No unwrap!
foreach ($relatedEntities as $relatedEntity) {
$this->doRemove($relatedEntity, $visited);
$entitiesToCascade[] = $relatedEntity;
}
break;
case ($relatedEntities !== null):
$this->doRemove($relatedEntities, $visited);
$entitiesToCascade[] = $relatedEntities;
break;
default:
// Do nothing
}
}
foreach ($entitiesToCascade as $relatedEntity) {
$this->doRemove($relatedEntity, $visited);
}
}
/**