From 44f2e22f1433fe704deb9b9e7a051b205070aa27 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 19 Aug 2017 18:30:33 +0200 Subject: [PATCH] #6303 #6304 documenting why collisions in field name hydration in STI/JTI require additional information and checks in the hydration process --- lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php index b90d77790..b38a212c9 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php @@ -294,6 +294,8 @@ abstract class AbstractHydrator $dqlAlias = $cacheKeyInfo['dqlAlias']; $type = $cacheKeyInfo['type']; + // If there are field name collisions in the child class, then we need + // to only hydrate if we are looking at the correct discriminator value if( isset($cacheKeyInfo['discriminatorColumn']) && isset($data[$cacheKeyInfo['discriminatorColumn']]) && @@ -392,7 +394,9 @@ abstract class AbstractHydrator 'dqlAlias' => $ownerMap, ]; - if($classMetadata->parentClasses && isset($this->_rsm->discriminatorColumns[$ownerMap])) { + // the current discriminator value must be saved in order to disambiguate fields hydration, + // should there be field name collisions + if ($classMetadata->parentClasses && isset($this->_rsm->discriminatorColumns[$ownerMap])) { return $this->_cache[$key] = \array_merge( $columnInfo, [