Skip to content

Commit 6f6a761

Browse files
mpdudegreg0ire
authored andcommitted
Fix #9095 by re-applying #9096
Since #10411 has been merged, no more need to specify all intermediate abstract entity classes. Thus, we can relax the schema validator check as requested in #9095. The reasons given in #9142 no longer apply. Fixes #9095 Closes #9096
1 parent 3843d7e commit 6f6a761

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

lib/Doctrine/ORM/Tools/SchemaValidator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public function validateClass(ClassMetadataInfo $class)
253253
}
254254
}
255255

256-
if (! $class->isInheritanceTypeNone() && ! $class->isRootEntity() && ! $class->isMappedSuperclass && array_search($class->name, $class->discriminatorMap, true) === false) {
256+
if (! $class->isInheritanceTypeNone() && ! $class->isRootEntity() && ($class->reflClass !== null && ! $class->reflClass->isAbstract()) && ! $class->isMappedSuperclass && array_search($class->name, $class->discriminatorMap, true) === false) {
257257
$ce[] = "Entity class '" . $class->name . "' is part of inheritance hierarchy, but is " .
258258
"not mapped in the root entity '" . $class->rootEntityName . "' discriminator map. " .
259259
'All subclasses must be listed in the discriminator map.';

tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php

+33
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,14 @@ public function testMappedSuperclassNotPresentInDiscriminator(): void
221221

222222
$this->assertEquals([], $ce);
223223
}
224+
225+
public function testAbstractChildClassNotPresentInDiscriminator(): void
226+
{
227+
$class1 = $this->em->getClassMetadata(Issue9095AbstractChild::class);
228+
$ce = $this->validator->validateClass($class1);
229+
230+
self::assertEmpty($ce);
231+
}
224232
}
225233

226234
/** @MappedSuperclass */
@@ -643,3 +651,28 @@ class EmbeddableWithAssociation
643651
*/
644652
private $cart;
645653
}
654+
655+
/**
656+
* @Entity
657+
* @InheritanceType("SINGLE_TABLE")
658+
* @DiscriminatorMap({"child" = Issue9095Child::class})
659+
*/
660+
abstract class Issue9095Parent
661+
{
662+
/**
663+
* @var mixed
664+
* @Id
665+
* @Column
666+
*/
667+
protected $key;
668+
}
669+
670+
/** @Entity */
671+
abstract class Issue9095AbstractChild extends Issue9095Parent
672+
{
673+
}
674+
675+
/** @Entity */
676+
class Issue9095Child extends Issue9095AbstractChild
677+
{
678+
}

0 commit comments

Comments
 (0)