From 288e3191ce7053d06fdc9c8c36480859d3b87791 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Mon, 6 Jun 2016 01:15:59 +0200 Subject: [PATCH] #5854 - simple workaround to avoid populating SLC cache from DQL queries with multiple nested DQL aliases --- lib/Doctrine/ORM/Cache/DefaultQueryCache.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php index 07c9d8f43..93363e996 100644 --- a/lib/Doctrine/ORM/Cache/DefaultQueryCache.php +++ b/lib/Doctrine/ORM/Cache/DefaultQueryCache.php @@ -261,6 +261,14 @@ class DefaultQueryCache implements QueryCache // @TODO - move to cache hydration components foreach ($rsm->relationMap as $alias => $name) { $metadata = $this->em->getClassMetadata($rsm->aliasMap[$rsm->parentAliasMap[$alias]]); + $className = $metadata->getName(); + + if (! $entity instanceof $className) { + // this alias is not the root alias, therefore we skip it. $entity is always the root of the selection here + // @TODO should actually cache all aliases + continue; + } + $assoc = $metadata->associationMappings[$name]; if (($assocValue = $metadata->getFieldValue($entity, $name)) === null || $assocValue instanceof Proxy) {