From 4bed15b9846932929294e6a0969ba8d867f428cc Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Thu, 5 Feb 2015 00:11:53 +0000 Subject: [PATCH] #1169 DDC-3343 - one-to-many persister should only interact with the data when `orphanRemoval` and `EXTRA_LAZY` are combined --- lib/Doctrine/ORM/Persisters/OneToManyPersister.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/ORM/Persisters/OneToManyPersister.php b/lib/Doctrine/ORM/Persisters/OneToManyPersister.php index cf39436d4..6e02272f4 100644 --- a/lib/Doctrine/ORM/Persisters/OneToManyPersister.php +++ b/lib/Doctrine/ORM/Persisters/OneToManyPersister.php @@ -223,6 +223,13 @@ class OneToManyPersister extends AbstractCollectionPersister */ public function removeElement(PersistentCollection $coll, $element) { + $mapping = $coll->getMapping(); + + if ( ! $mapping['orphanRemoval']) { + // no-op: this is not the owning side, therefore no operations should be applied + return false; + } + $uow = $this->em->getUnitOfWork(); // shortcut for new entities @@ -238,9 +245,9 @@ class OneToManyPersister extends AbstractCollectionPersister return false; } - $mapping = $coll->getMapping(); - $persister = $this->uow->getEntityPersister($mapping['targetEntity']); - $targetMetadata = $this->em->getClassMetadata($mapping['targetEntity']); + $class = $this->em->getClassMetadata($mapping['targetEntity']); + $sql = 'DELETE FROM ' . $this->quoteStrategy->getTableName($class, $this->platform) + . ' WHERE ' . implode('= ? AND ', $class->getIdentifierColumnNames()) . ' = ?'; if ($element instanceof Proxy && ! $element->__isInitialized()) { $element->__load();