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
[Doctrine Bridge] Class "%s" is not a valid entity or mapped super class - BC Break #47791
Comments
Can you create a small example application that allows to reproduce your issue? |
Erf! Will try to do that tomorrow |
I'm not familiar with reproducers: this is my first one, hope it's ok |
I know this issue. I stumbled accross it myself recently and investigated it already. If a bundle does not ship any entities but only ebeddables, our detection logic fails and DoctrineBundle assumes that the bundle is using attributes for mapping. You have two options:
|
I wasn't really sure how to fix it at that time and assumed that the issue would be rare enough to leave it unfixed. But if someone finds a solution, I'll be glad to review and merge it. |
It's work with something like that in Symfony\Bridge\Doctrine\DependencyInjection\AbstractDoctrineExtension::detectMappingType() (l316) if (preg_match('/^ \* @.*'.$quotedMappingObjectName.'\b/m', $content)) {
$type = 'annotation';
break;
} --> $quotedMappingEmbeddable = preg_quote('Embeddable', '/');
if (
preg_match('/^ \* @.*'.$quotedMappingObjectName.'\b/m', $content) ||
preg_match('/^ \* @.*'.$quotedMappingEmbeddable.'\b/m', $content)
) {
$type = 'annotation';
break;
} |
Symfony version(s) affected
5.4.x
Description
Hello
The upgrade from Symfony 5.3.x to Symfony 5.4.x led to multiple
MappingException
in one of my project.From what I could investigate, I think that this commit could be at the origin of - what I consider being a - BC Break as it changes the default value of mapping type from "annotation" to "attribute" in the following use case.
What I describe below is working properly in Symfony 5.3.x.
How to reproduce
I'm on a legacy project separated into bundles.
One of that bundle provides an embeddable class in an
Entity
folder.App\FooBundle\Entity
, only the embeddable.Then Another bundle contains an entity using that embeddable
and the doctrine configuration is the following:
Possible Solution
The solution I found is to explicitly define the mapping type in doctrine configuration
I don't know if any change has to be done regarding the code itself, maybe it requires an additional row in this part of the upgrade documentation.
Additional Context
No response
The text was updated successfully, but these errors were encountered: