-
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
Resolve Target Entity Listener not longer working like expected #10552
Comments
The target entity class mentioned in the error message: Is that the result of running the ResolveTargetEntityListener? Or is that the (abstract) class that should have been resolved? |
If it is the resolved class, is it an |
@mpdude the So it could maybe be that now doctrine/orm accesses the metadata before the |
Let's see – #10473 caused this. That change moved a configuration consistency check to another place and relaxed the requirements a little. Until now, when the ClassMetadataFactory loads the mapping configuration for a class, it will check whether the class is a mapped superclass (MS) and contains a one-to-many association. If so, an exception would be thrown. The reason: A MS cannot declare a one-to-many association, since that means the referred-to entity would have to contain the foreign key pointing back to it. But since a MS does not have a database table, that's not possible. What I did in #10473 is to postpone this check and do it the other way round:
I have described with an example in #10473 why this is useful. Now that leads to the ClassMetadataFactory (CMF) asking a new question – is a class given as a Since this question is asked during the runtime metadata validation (while the CMF loads a particular class), we cannot use the CMF itself to get the full data about the referred-to class. It does not support this kind of re-entrant loading. But, we also don't need the full data, we just need to know whether it's an entity or not. We already have If I get you right, in your case there is no driver involved that could be used here. You're using a custom metadata event listener that will hook into the CMF and provide mapping configuratoin. Is that correct? |
Our mapped super classes are in some kind converted into normal entities by our Persistence Bundle Metadatalistener, sadly I'm not very deep in that logic but it is used in our case used to allow a project overwrite our entities, when the project does not overwrite it its just a normal entity, for referencing that entities which are overwritable a Interface is used via Doctrine ResolveTargetEntityListener. So in our case a MetadataListener with a very high priority is registered here which is handling the mapped superclasses relations:
Yes the one listenered above is used to set our Metadata correctly for that special overwritable entities, we also have a lot other listeners doing things like Blameable, Timestampable, ... (little bit similar to the Doctrine Gedmo Extensions), so the Metadata is only correct after all Listenes are called.
In our case there are a lot #10554 seems to fix the issue the CI runs without errors using that branch: https://github.com/sulu/sulu/actions/runs/4311605614/jobs/7521179740 |
Glad to hear #10554 works for now 👍. I am terrified to hear about the tricks you seem to employ in Sulu. Not to say that what you're doing is wrong or not allowed – you only stress the mapping-related components of the ORM even more than I do, and I thought I'd be an exceptional example. So, be aware that the This is only about discovering entity subclasses that for good reasons need not be declared in a discriminator map. I am reasonably sure this does not cause regressions for you. But maybe some of the problems I thought were fixed with #10411 still exist when mapping configuration is loaded "the Sulu way". |
Want to mention that this logic isn't something implemented newly and used since more then 8 years inside @sulu CMS and as I know also in the @Sylius Ecommerce System to allow overwriting of Entities inside projects, I'm not aware of current state in @Sylius but I will ping a developer there to test it also. I'm aware that its a specific usecase normal Projects never have and only packages like us will have, but for Systems like @sulu and @Sylius it are some requirement to be here flexible enough and decide things inside the |
I also tested @Sylius and they currently run into the same issue with Was not yet able to run there tests again your pull request as the CI does use github token for authentication and so composer currently fails to test against a fork. Will try to ask @Sylius core team member for help so we can also test @Sylius against your changes to check it also fixes there problem. Pinged @lchrusciel about it. |
Good news first @Sylius seems also not longer run into the error with merged #10554. Strangely I'm running now into an other error with Gedmo Extensions: Doctrine\ORM\Mapping\MappingException: libxml error: Element '{http://gediminasm.org/schemas/orm/doctrine-extensions-mapping}tree-left': No matching global element declaration available, but demanded by the strict wildcard.
in /home/runner/work/sulu/sulu/src/Sulu/Bundle/MediaBundle/Resources/config/doctrine/Collection.orm.xml at line 13
libxml error: Element '{http://gediminasm.org/schemas/orm/doctrine-extensions-mapping}tree-right': No matching global element declaration available, but demanded by the strict wildcard. Not yet sure if the issue is on gedmo side or orm side. Need to debug it deeper but if somebody has a hint let me know. |
This seems not to be related with this issue, is it? |
It seems not related to this issue but currently blocks to test if all works. Today it also failed on the stable branch so it seems like a change in |
Yes, I confirm, in version 2.14.2, get a similar error:
However, in version 2.14.1 - everything works |
I guess next step would be using |
maybe: #10579 |
I don't know where I saw that value of Can you try that and report back? If that works, please send a PR. |
yes, i try and confirm.
The version before this commit works: |
This is getting off track, what you're discussing has nothing to do with the initial report. Just sayin'. |
Oh, and #10554 which addresses the initial report has been merged, so maybe this issue here should be closed/marked as fixed? |
Bug Report
Summary
Our tests against
@dev
versions are currently failing with the dev version of doctrine/orm and it ssems like the EntityTargetResolver is not longer working like expected in current@dev
version.We have some special handling for resolved targets and they are not configured via the doctrine bundle instead we are adding the resolved targets inside an own compilerpass not sure if that could cause an issue now: https://github.com/sulu/sulu/blob/57bf8c4dcc59361033ef6d7acc5898b850f15b5c/src/Sulu/Bundle/PersistenceBundle/DependencyInjection/Compiler/ResolveTargetEntitiesPass.php#L50-L51. There is some special handling behind which not only @sulu but also @Sylius use to make things easier overwritable.
The last commit where the CI did run was
979b3dcb8df6815caef022d78262bcfa232238fc
so it must be some of this changes:979b3dc...2.15.x
The changes from @mpdude looks releated to the EntityResolveListener: #10473
Current behavior
Stack Trace:
How to reproduce
Expected behavior
Entities which are mapped via the ResolvedTargetListener should befound like before.
The text was updated successfully, but these errors were encountered: