-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolving target entity in discriminator map omits fields from subtables #8402
Resolving target entity in discriminator map omits fields from subtables #8402
Conversation
Apparently, this might be fixed if the You added this code in #1257. My guess is that, apart from the check that all classes are part of the DiscriminatorMap, it is no longer necessary when the Maybe this method could even be removed altogether and the check added in |
@beberlei If from your work on #8378 (fixing #6578) you have additional insight on edge cases related to invalid Discriminator Map definitions, I'd be glad to hear from you! |
aa04876
to
2bfbe2b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a valid bugfix, because the Events::loadClassMetadata
is triggered inside AbstractClassMetadataFactory::loadMetadata
and the logic from resolveDiscriminatorValue
seems to be replaced correctly by the simple foreach in ResolveTargetEntityListener
.
I am wondering though resolveDiscriminatorValue
chanes $metadata->discrimintorValue
, does this happen elsewhere now?
@mpdude needs to be rebased on 2.8.x as this is the bugfix target at the moment. |
2bfbe2b
to
0e19d61
Compare
Rebased to @beberlei regarding your comment
I am not exactly sure what you're out for... The only write access to My guess is that this will be called on every Since the resolution of interfaces to concrete classes now happens before that, we should already be looking a the classes (not intefaces anymore) in this place... Not sure, does this answer your question? |
0e19d61
to
c59a214
Compare
Rebased against |
a44dd97
to
e57c3b7
Compare
6e70a9f
to
ab1eefe
Compare
@beberlei I've rebased this onto Given that you already had a look at this and basically agreed, could you please advise me what changes, clarifications or additional tests you'd like to see to make it a 👍? |
7ad72e4
to
ab1eefe
Compare
How can I make PHPStan/Psalm happy with regards to The second argument Changing it to |
An easy way to fix this should be to use |
@greg0ire Thank you for the hint! I guess it makes only sense to open the other PR once this PR here is merged, right? |
I think both issues and PR are independent, feel free to work on it now if you want to. |
Thanks @mpdude ! I took the liberty of squashing your commits, as most of them were amending the main one. |
ORM 2.8 is end of life and this will not be backported, right? |
Correct 👍 |
#1257 introduced the possibility to use interfaces instead of concrete classes also in the DiscriminatorMap. Here's an example config:
/** @DiscriminatorMap({"foo" = "FooInterface", "bar" = "BarConcreteImpl"}) */
The
ResolveTargetEntityListener
would be used to resolve such interface references to concrete classes at runtime.The feature is currently broken. Core of the issue seems to be that
\Doctrine\ORM\Mapping\ClassMetadataInfo::$subClasses
is not populated with the concrete classes. This proably has to do with the resolution taking place too late, although I do not fully understand where this happens.Example test failure before the change: https://github.com/doctrine/orm/pull/8402/checks?check_run_id=1587762816#step:7:73. The test case failed because the columns necessary for the subclasses are not created, but if they were (in an existing schema), the loaded entities would also lack data for their respective fields.
PR is against 2.7.x where the feature was introduced, since I did not find any documentation on PR policies/target branches.