mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Edge-case regression with 2.9.x #6750
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?
Originally created by @albe on GitHub (Jun 8, 2021).
We (neos/flow framework) suffer from a slight change in expectations for some annotation classes since #8266 - namely the
ManyToOne,ManyToManyandEmbeddednow have a required first constructor argument. While those arguments were always considered "required" in a pure doctrine environment, we partially enhanced the DX by extracting some information for the annotations from other reflection data (like thetargetEntity/classthe annotation targets). Hence we have usage of doctrine annotations like:which now breaks, because the ManyToMany is attempted to be constructed with
nullastargetEntityin the DocParser. Until now we solved the "missing" targetEntity (and other things) via a customAnnotationDriverand that worked out quite nicely. With this change we are at a loss though, because we'd need to hook into the DocParser now, which happens way too early.See https://github.com/neos/flow-development-collection/issues/2487#issuecomment-850405128
While we can "solve" this by restricting doctrine/orm to <2.9, we would also like to move towards PHP8 support and attributes. For us the best solution would be if those three constructors would allow
nullfor their first argument, but I understand that would mean you'd need to check for thatnullat runtime which is a step backward. Optimally the Annotation would not be instanciated until it is used for mapping, but that would be too great a change.Are there any other possible ways to "enhance" the annotations and hook into the instanciation process?
@albe commented on GitHub (Jun 8, 2021):
friendly ping @beberlei @greg0ire
@greg0ire commented on GitHub (Jun 9, 2021):
@var SomeEntityShouldn't that be
@var ArrayCollection<int, SomeEntity>, or are you really using it that way?Anyway, adding these constructors was technically a BC break, so it would make sense to me to allow
nulluntil next major to give you some wiggle room. A deprecation would have to be triggered whennullis passed.@beberlei commented on GitHub (Jun 9, 2021):
Yes that makes sense, can you make a PR for that change? Including the deprecation about nullability if the value is passed this way to the attribute/annotation class:
@greg0ire commented on GitHub (Jun 9, 2021):
I can give it a try, yes
@greg0ire commented on GitHub (Jun 9, 2021):
Wait, this has already been fixed in
a2230485b2, hasn't it? The only thing that seems to be missing are deprecations…@albe commented on GitHub (Jun 9, 2021):
Yes, indeed. That was just an error in the manually typed example code :)
👀 That does indeed seem to fix it for ManyToOne annotation, but I can't see the same change for ManyToMany (https://github.com/doctrine/orm/blob/2.9.x/lib/Doctrine/ORM/Mapping/ManyToMany.php#L64)? Embedded seems to be changed already in https://github.com/doctrine/orm/pull/8724
@greg0ire commented on GitHub (Jun 9, 2021):
Ah indeed,
ManyToManyneeds to be handled as well 👍