From a2a400b8fb71c938e2722738b9755dcace1e86b0 Mon Sep 17 00:00:00 2001 From: Kris Pypen Date: Fri, 3 Jul 2015 14:45:25 +0200 Subject: [PATCH] Fix second level caching for queries with multiple joins The $metadata of the main entity is not always the metadata you need here, for example when you do join A with B and then B with C. For the second join it was using the metadata from A. --- lib/Doctrine/ORM/Cache/DefaultQueryCache.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php index 87bb13663..2d15c3c25 100644 --- a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php @@ -259,7 +259,8 @@ class DefaultQueryCache implements QueryCache } // @TODO - move to cache hydration components - foreach ($rsm->relationMap as $name) { + foreach ($rsm->relationMap as $alias => $name) { + $metadata = $this->em->getClassMetadata($rsm->aliasMap[$rsm->parentAliasMap[$alias]]); $assoc = $metadata->associationMappings[$name]; if (($assocValue = $metadata->getFieldValue($entity, $name)) === null || $assocValue instanceof Proxy) {