Skip to content

Commit

Permalink
Fix doctrine#9095 by re-applying doctrine#9096
Browse files Browse the repository at this point in the history
Since doctrine#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 doctrine#9095. The
reasons given in doctrine#9142 no longer apply.

Fixes doctrine#9095
  • Loading branch information
mpdude authored and greg0ire committed Feb 5, 2023
1 parent d038f23 commit ee8269e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/Doctrine/ORM/Tools/SchemaValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand Down
33 changes: 33 additions & 0 deletions tests/Doctrine/Tests/ORM/Tools/SchemaValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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
{
}

0 comments on commit ee8269e

Please sign in to comment.