Skip to content

Commit 02a0732

Browse files
committed
bug symfony#60953 [DoctrineBridge] Restore compatibility with Doctrine ODM (pepeh)
This PR was merged into the 6.4 branch. Discussion ---------- [DoctrineBridge] Restore compatibility with Doctrine ODM | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix symfony#60921 | License | MIT Ensure that the metadata class being inspected is an instance of Doctrine\ORM\Mapping\ClassMetadata to fix ODM integration when both ODM and ORM packages are installed in the same Symfony project. Commits ------- 665f927 [DoctrineBridge] Restore compatibility with Doctrine ODM by validating $class object type
2 parents bd60612 + 665f927 commit 02a0732

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Validator\Constraints;
1313

14-
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
1514
use Doctrine\Persistence\ManagerRegistry;
1615
use Doctrine\Persistence\Mapping\ClassMetadata;
1716
use Doctrine\Persistence\ObjectManager;
@@ -93,7 +92,7 @@ public function validate(mixed $entity, Constraint $constraint)
9392
throw new ConstraintDefinitionException(sprintf('The field "%s" is not mapped by Doctrine, so it cannot be validated for uniqueness.', $fieldName));
9493
}
9594

96-
if (property_exists(OrmClassMetadata::class, 'propertyAccessors')) {
95+
if (property_exists($class, 'propertyAccessors')) {
9796
$fieldValue = $class->propertyAccessors[$fieldName]->getValue($entity);
9897
} else {
9998
$fieldValue = $class->reflFields[$fieldName]->getValue($entity);

0 commit comments

Comments
 (0)