mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
[PR #10554] Make "targetEntity must not be a mapped superclass" a lazy check #12449
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Original Pull Request: https://github.com/doctrine/orm/pull/10554
State: closed
Merged: Yes
#10473 relaxed the runtime check that mapped superclasses must not use one-to-many associations. It turned the check the other way round, so that no mapped superclass may be used as the
targetEntityof an association.To find out whether a class is a mapped superclass, the
\Doctrine\ORM\Mapping\ClassMetadataFactory::peekIfIsMappedSuperclassmethod was used, which is directly using the mapping driver.#10552 reports a case where mapping configuration is not collected through the driver alone, but also a metadata listener is contributing relevant information. Updating metadata with a listener is currently not supported by the check in that method.
Also, https://github.com/doctrine/orm/pull/10473#issuecomment-1450048660 has a mapping configuration that cannot be loaded in the improvised way that
\Doctrine\ORM\Mapping\ClassMetadataFactory::peekIfIsMappedSuperclassemploys.As I explained in https://github.com/doctrine/orm/issues/10552#issuecomment-1450794332, we cannot use the full ClassMetadataFactory itself to obtain information about the
targetEntitywhile we're performing runtime validation for another class currently being loaded.So, I don't see any other way than to make this check a non-runtime (offline?) check in the
SchemaValidator. There, we can first completely load metadata for all classes and then inspect it.Many fixes to the test models that were made in #10473 can be reverted, since these files are no longer scrutinized at runtime, and we probably don't care about the extra validation checks that much.