From 7948b0c160adc78540eb86494b0ae6b5f8f48f14 Mon Sep 17 00:00:00 2001 From: Asmir Mustafic Date: Thu, 29 Jan 2015 22:16:25 +0100 Subject: [PATCH] Identity map check --- lib/Doctrine/ORM/Utility/IdentifierFlattener.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php b/lib/Doctrine/ORM/Utility/IdentifierFlattener.php index bb6e33464..9108c35c8 100644 --- a/lib/Doctrine/ORM/Utility/IdentifierFlattener.php +++ b/lib/Doctrine/ORM/Utility/IdentifierFlattener.php @@ -78,7 +78,13 @@ final class IdentifierFlattener $targetClassMetadata = $this->metadataFactory->getMetadataFor( $class->associationMappings[$field]['targetEntity'] ); - $associatedId = $this->flattenIdentifier($targetClassMetadata, $this->unitOfWork->getEntityIdentifier($id[$field])); + + if ($this->unitOfWork->isInIdentityMap($id[$field])) { + $associatedId = $this->flattenIdentifier($targetClassMetadata, $this->unitOfWork->getEntityIdentifier($id[$field])); + } else { + $associatedId = $this->flattenIdentifier($targetClassMetadata, $targetClassMetadata->getIdentifierValues($id[$field])); + } + $flatId[$field] = implode(' ', $associatedId); } elseif (isset($class->associationMappings[$field])) { $associatedId = array(); @@ -90,7 +96,6 @@ final class IdentifierFlattener $flatId[$field] = $id[$field]; } } - return $flatId; }