mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[PR #10449] Failing test: Illegal to-many association on MappedSuperclass not rejected #12373
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/10449
State: closed
Merged: No
Closing since this is no longer an error condition we need to check for.
#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 targetEntity of an association. (In addition, #10554 also made it a "lazy" (non-runtime) check in the schema validator.)
This test case demonstrates a situation where an invalid to-many association on a mapped superclass is not being detected.
Since at least the annotations and attribute drivers currently skip non-private properties from mapped superclasses (see #10417), the
ClassMetadataFactoryis not even aware of the association on the mapped superclass and so cannot reject it.IMHO, we should bail out as soon as we detect this on the mapped superclass. I don't see how we could proceed at that time and try to rescue/fixup the situation afterwards.
In addition to that, maybe an association with a
targetthat is a mapped superclass should be rejected in its own right?More details on what happens down the road, just for the sake of completeness:
When the mapping driver processes the entity class with the inherited association, PHP reflection will report the association property. Since the association was not reported for the mapped superclass, the driver thinks (see #10417) this is a "new" (non-inherited) field and reports to the
ClassMetadataFactory.The association will show up as being from
GH10449EntitytoGH10449ToManyAssociationTarget. OnGH10449ToManyAssociationTarget, it will refer back toGH10449MappedSuperclass.