Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement BC compatibel BackedEnum switch #10158

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,13 @@ private function getEntityFromIdentityMap(string $className, array $data)
$idHash = '';

foreach ($class->identifier as $fieldName) {
$idHash .= ' ' . (isset($class->associationMappings[$fieldName])
? $data[$class->associationMappings[$fieldName]['joinColumns'][0]['name']]
: $data[$fieldName]);
if (isset($class->associationMappings[$fieldName])) {
$idHash .= ' ' . $data[$class->associationMappings[$fieldName]['joinColumns'][0]['name']];
} elseif (class_exists('\BackedEnum') && is_a($data[$fieldName], '\BackedEnum')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class_exists() feels unnecessary and also wrong, given that BackedEnum is actually an interface.

$idHash .= ' ' . $data[$fieldName]->value;
} else {
$idHash .= ' ' . $data[$fieldName];
}
}

return $this->_uow->tryGetByIdHash(ltrim($idHash), $class->rootEntityName);
Expand Down