From 9eaac1361574937b6dd473b0f4d1aa9c2aaf1e03 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Tue, 27 Jan 2015 06:27:37 +0100 Subject: [PATCH] #1169 DDC-3343 - correcting one-to-many persister - association should not be updated directly if no orphan removal is involved --- .../ORM/Persisters/Collection/OneToManyPersister.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php index 9dc2fad54..fab5e9393 100644 --- a/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/Collection/OneToManyPersister.php @@ -157,11 +157,17 @@ class OneToManyPersister extends AbstractCollectionPersister */ public function removeElement(PersistentCollection $collection, $element) { + $mapping = $collection->getMapping(); + + if ( ! $mapping['orphanRemoval']) { + // no-op: this is not the owning side, therefore no operations should be applied + return false; + } + if ( ! $this->isValidEntityState($element)) { return false; } - $mapping = $collection->getMapping(); $persister = $this->uow->getEntityPersister($mapping['targetEntity']); $targetMetadata = $this->em->getClassMetadata($mapping['targetEntity']);