diff --git a/lib/Doctrine/ORM/Tools/SchemaValidator.php b/lib/Doctrine/ORM/Tools/SchemaValidator.php index 4bca9a4e4f2..2d71e7d51d0 100644 --- a/lib/Doctrine/ORM/Tools/SchemaValidator.php +++ b/lib/Doctrine/ORM/Tools/SchemaValidator.php @@ -256,6 +256,7 @@ public function validateClass(ClassMetadataInfo $class) if ( ! $class->isInheritanceTypeNone() && ! $class->isRootEntity() + && ($class->reflClass !== null && ! $class->reflClass->isAbstract()) && ! $class->isMappedSuperclass && array_search($class->name, $class->discriminatorMap, true) === false ) { diff --git a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php index d18799802b8..61a4c7c273d 100644 --- a/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php @@ -221,6 +221,14 @@ public function testMappedSuperclassNotPresentInDiscriminator(): void $this->assertEquals([], $ce); } + + public function testAbstractChildClassNotPresentInDiscriminator(): void + { + $class1 = $this->em->getClassMetadata(Issue9095AbstractChild::class); + $ce = $this->validator->validateClass($class1); + + self::assertEmpty($ce); + } } /** @MappedSuperclass */ @@ -643,3 +651,28 @@ class EmbeddableWithAssociation */ private $cart; } + +/** + * @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 +{ +}