diff --git a/lib/Doctrine/ORM/Tools/SchemaValidator.php b/lib/Doctrine/ORM/Tools/SchemaValidator.php index db27180cdc9..c8535b42a88 100644 --- a/lib/Doctrine/ORM/Tools/SchemaValidator.php +++ b/lib/Doctrine/ORM/Tools/SchemaValidator.php @@ -239,7 +239,7 @@ public function validateClass(ClassMetadataInfo $class) } } - if (! $class->isInheritanceTypeNone() && ! $class->isRootEntity() && ! $class->isMappedSuperclass && array_search($class->name, $class->discriminatorMap, true) === false) { + if (! $class->isInheritanceTypeNone() && ! $class->isRootEntity() && ! $class->reflClass->isAbstract() && ! $class->isMappedSuperclass && array_search($class->name, $class->discriminatorMap, true) === false) { $ce[] = "Entity class '" . $class->name . "' is part of inheritance hierarchy, but is " . "not mapped in the root entity '" . $class->rootEntityName . "' discriminator map. " . 'All subclasses must be listed in the discriminator map.'; diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php index 58c5aca7f76..2c5ea7b4907 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php @@ -225,6 +225,17 @@ public function testMappedSuperclassNotPresentInDiscriminator(): void $this->assertEquals([], $ce); } + + /** + * @group 9095 + */ + public function testAbstractChildClassNotPresentInDiscriminator(): void + { + $class1 = $this->em->getClassMetadata(Issue9095AbstractChild::class); + $ce = $this->validator->validateClass($class1); + + $this->assertEquals([], $ce); + } } /** @@ -256,6 +267,35 @@ class ChildEntity extends MappedSuperclassEntity { } +/** + * @Entity + * @InheritanceType("SINGLE_TABLE") + * @DiscriminatorMap({"child" = Issue9095Child::class}) + */ +abstract class Issue9095Parent +{ + /** + * @var mixed + * @Id + * @Column + */ + protected $key; +} + +/** + * @Entity + */ +abstract class Issue9095AbstractChild extends Issue9095Parent +{ +} + +/** + * @Entity + */ +class Issue9095Child extends Issue9095AbstractChild +{ +} + /** * @Entity */