-
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
[GH-8229] Prevent Illegal Inheritance Override #8348
Conversation
…only allowed for MappedSuperclass
…, only allowed for MappedSuperclass
…octrine#8329)" This reverts commit f4ebded.
// TODO: Deprecate overriding the fetch mode via association override for 3.0, | ||
// users should do this with a listener and a custom attribute/annotation | ||
throw MappingException::illegalOverrideOfInheritedProperty($this->name, $fieldName); | ||
} |
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.
Should the parts that are about throwing be contributed to 2.8 instead? If we think there are people currently using this, we should probably not have it blow up in their face in a patch
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.
You are right, i should remove them for 2.7, and re-introduce them for 2.8
I think this update just severely broke my application. I'm still debugging, however, I use a ClassMetadataSubscriber to override the [name] field on the Entities to match a prefix. ie. You know how wordpess prefixes based on Anyway, I have a MappedSuperclass called.. "Building", and then I have on entity which extends it, called "Room". It appears now, as though the MappedSuperClass "Building" does not existing within the Is this intended? It loosk like all MapperSuperClasses have been removed, so any of my superclasses now do not exist with the vendor prefix. What ended up happening on my development machine was 20 table deletions.. so it's quite a big issue which I didn't expect from a minor patch? |
Please open up a new issue and improve the issue description, I don't understand mapped superclasses do not have tables, and should not have table prefixes. What means "not existing within LoadClassMetadataEventArgs"? |
#10431 suggests adding a runtime check for missing inheritance declarations |
Inheritance has to be declared as soon as one entity class extends (directly or through middle classes) another one. This is also pointed out in the opening comment for doctrine#8348: > Entities are not allowed to extend from entities without an inheritence mapping relationship (Single Table or Joined Table inheritance). [...] While Doctrine so far allowed these things, they are fragile and will break on certain scenarios. Throwing an exception in case of this misconfiguration is nothing we should do light-heartedly, given that it may surprise users in a bugfix or feature release. So, we should start with a deprecation notice and make this an exception in 3.0. The documentation is updated accordingly at doctrine#10429. Catching missing inheritance declarations early on is important to avoid weird errors further down the road, giving users a clear indication of the root cause. In case you are affected by this, please understand that although things "previously worked" for you, you have been using the ORM outside of what it was designed to do. That may have worked in simple cases, but may also have caused invalid results (wrong or missing data after hydration?) that possibly went unnoticed in subtle cases.
Inheritance has to be declared as soon as one entity class extends (directly or through middle classes) another one. This is also pointed out in the opening comment for doctrine#8348: > Entities are not allowed to extend from entities without an inheritence mapping relationship (Single Table or Joined Table inheritance). [...] While Doctrine so far allowed these things, they are fragile and will break on certain scenarios. Throwing an exception in case of this misconfiguration is nothing we should do light-heartedly, given that it may surprise users in a bugfix or feature release. So, we should start with a deprecation notice and make this an exception in 3.0. The documentation is updated accordingly at doctrine#10429. Catching missing inheritance declarations early on is important to avoid weird errors further down the road, giving users a clear indication of the root cause. In case you are affected by this, please understand that although things "previously worked" for you, you have been using the ORM outside of what it was designed to do. That may have worked in simple cases, but may also have caused invalid results (wrong or missing data after hydration?) that possibly went unnoticed in subtle cases.
Inheritance has to be declared as soon as one entity class extends (directly or through middle classes) another one. This is also pointed out in the opening comment for doctrine#8348: > Entities are not allowed to extend from entities without an inheritence mapping relationship (Single Table or Joined Table inheritance). [...] While Doctrine so far allowed these things, they are fragile and will break on certain scenarios. Throwing an exception in case of this misconfiguration is nothing we should do light-heartedly, given that it may surprise users in a bugfix or feature release. So, we should start with a deprecation notice and make this an exception in 3.0. The documentation is updated accordingly at doctrine#10429. Catching missing inheritance declarations early on is important to avoid weird errors further down the road, giving users a clear indication of the root cause. In case you are affected by this, please understand that although things "previously worked" for you, you have been using the ORM outside of what it was designed to do. That may have worked in simple cases, but may also have caused invalid results (wrong or missing data after hydration?) that possibly went unnoticed in subtle cases.
Inheritance has to be declared as soon as one entity class extends (directly or through middle classes) another one. This is also pointed out in the opening comment for doctrine#8348: > Entities are not allowed to extend from entities without an inheritence mapping relationship (Single Table or Joined Table inheritance). [...] While Doctrine so far allowed these things, they are fragile and will break on certain scenarios. Throwing an exception in case of this misconfiguration is nothing we should do light-heartedly, given that it may surprise users in a bugfix or feature release. So, we should start with a deprecation notice and make this an exception in 3.0. The documentation is updated accordingly at doctrine#10429. Catching missing inheritance declarations early on is important to avoid weird errors further down the road, giving users a clear indication of the root cause. In case you are affected by this, please understand that although things "previously worked" for you, you have been using the ORM outside of what it was designed to do. That may have worked in simple cases, but may also have caused invalid results (wrong or missing data after hydration?) that possibly went unnoticed in subtle cases.
Inheritance has to be declared as soon as one entity class extends (directly or through middle classes) another one. This is also pointed out in the opening comment for #8348: > Entities are not allowed to extend from entities without an inheritence mapping relationship (Single Table or Joined Table inheritance). [...] While Doctrine so far allowed these things, they are fragile and will break on certain scenarios. Throwing an exception in case of this misconfiguration is nothing we should do light-heartedly, given that it may surprise users in a bugfix or feature release. So, we should start with a deprecation notice and make this an exception in 3.0. The documentation is updated accordingly at #10429. Catching missing inheritance declarations early on is important to avoid weird errors further down the road, giving users a clear indication of the root cause. In case you are affected by this, please understand that although things "previously worked" for you, you have been using the ORM outside of what it was designed to do. That may have worked in simple cases, but may also have caused invalid results (wrong or missing data after hydration?) that possibly went unnoticed in subtle cases.
…ridden This was brought up in doctrine#8348, but seemingly forgotten to be implenented in later versions. Closes doctrine#10289.
…ridden This was brought up in doctrine#8348, but seemingly forgotten to be implenented in later versions. Closes doctrine#10289.
The PRs #8234 and #8329 are based on a flawed understanding of inheritance in Doctrine and need to be reverted:
Attribute/Association Overrides are only allowed to be used for MappedSuperclass and Traits. This is documented, albeit not phrased strongly enough: https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/inheritance-mapping.html#overrides
Entities are not allowed to extend from entities without an inheritence mapping relationship (Single Table or Joined Table inheritance). If you have this use case you should instead have two entities and they each extend a common
@MappedSuperclass
.One excemption was made to use
@AssocationOVerride
only for changing the fetch strategy. Soft-deprecated this with a TODO.While Doctrine so far allowed these things, they are fragile and will break on certain scenarios. Please give feedback here or in new issues on the impact of this change on your projects.