Remove loose comparison on discriminator values
According to mapping drivers the discriminator values can always be converted to strings so it's safe to assume that we can actually do a strict comparison during hydration.
This commit is contained in:
parent
48ca6dbcec
commit
2905b435db
@ -299,8 +299,7 @@ abstract class AbstractHydrator
|
|||||||
// If there are field name collisions in the child class, then we need
|
// 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
|
// to only hydrate if we are looking at the correct discriminator value
|
||||||
if (isset($cacheKeyInfo['discriminatorColumn'], $data[$cacheKeyInfo['discriminatorColumn']])
|
if (isset($cacheKeyInfo['discriminatorColumn'], $data[$cacheKeyInfo['discriminatorColumn']])
|
||||||
// Note: loose comparison required. See https://github.com/doctrine/doctrine2/pull/6304#issuecomment-323294442
|
&& ! in_array((string) $data[$cacheKeyInfo['discriminatorColumn']], $cacheKeyInfo['discriminatorValues'], true)
|
||||||
&& ! in_array($data[$cacheKeyInfo['discriminatorColumn']], $cacheKeyInfo['discriminatorValues'])
|
|
||||||
) {
|
) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -398,13 +397,13 @@ abstract class AbstractHydrator
|
|||||||
// should there be field name collisions
|
// should there be field name collisions
|
||||||
if ($classMetadata->parentClasses && isset($this->_rsm->discriminatorColumns[$ownerMap])) {
|
if ($classMetadata->parentClasses && isset($this->_rsm->discriminatorColumns[$ownerMap])) {
|
||||||
$discriminatorValues = array_map(
|
$discriminatorValues = array_map(
|
||||||
function (string $subClass) {
|
function (string $subClass) : string {
|
||||||
return $this->getClassMetadata($subClass)->discriminatorValue;
|
return (string) $this->getClassMetadata($subClass)->discriminatorValue;
|
||||||
},
|
},
|
||||||
$classMetadata->subClasses
|
$classMetadata->subClasses
|
||||||
);
|
);
|
||||||
|
|
||||||
$discriminatorValues[] = $classMetadata->discriminatorValue;
|
$discriminatorValues[] = (string) $classMetadata->discriminatorValue;
|
||||||
|
|
||||||
return $this->_cache[$key] = \array_merge(
|
return $this->_cache[$key] = \array_merge(
|
||||||
$columnInfo,
|
$columnInfo,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user