Skip to content
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

Edge-case regression with 2.9.x #8753

Closed
albe opened this issue Jun 8, 2021 · 7 comments
Closed

Edge-case regression with 2.9.x #8753

albe opened this issue Jun 8, 2021 · 7 comments
Milestone

Comments

@albe
Copy link
Contributor

albe commented Jun 8, 2021

We (neos/flow framework) suffer from a slight change in expectations for some annotation classes since #8266 - namely the ManyToOne, ManyToMany and Embedded now 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 the targetEntity/class the annotation targets). Hence we have usage of doctrine annotations like:

@var Collection<SomeEntity>
@ORM\ManyToMany

which now breaks, because the ManyToMany is attempted to be constructed with null as targetEntity in the DocParser. Until now we solved the "missing" targetEntity (and other things) via a custom AnnotationDriver and 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 neos/flow-development-collection#2487 (comment)

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 null for their first argument, but I understand that would mean you'd need to check for that null at 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
Copy link
Contributor Author

albe commented Jun 8, 2021

friendly ping @beberlei @greg0ire

@greg0ire
Copy link
Member

greg0ire commented Jun 9, 2021

@var SomeEntity

Shouldn'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 null until next major to give you some wiggle room. A deprecation would have to be triggered when null is passed.

@beberlei
Copy link
Member

beberlei commented 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:

Deprecation::trigger('doctrine/orm', 'https://github.com/doctrine/orm/issues/8753', 'Passing no target entity is deprecated.');

@beberlei beberlei added this to the 2.9.3 milestone Jun 9, 2021
@greg0ire
Copy link
Member

greg0ire commented Jun 9, 2021

I can give it a try, yes

@greg0ire
Copy link
Member

greg0ire commented Jun 9, 2021

Wait, this has already been fixed in a223048, hasn't it? The only thing that seems to be missing are deprecations…

@albe
Copy link
Contributor Author

albe commented Jun 9, 2021

Shouldn't that be @var ArrayCollection<int, SomeEntity>, or are you really using it that way?

Yes, indeed. That was just an error in the manually typed example code :)

Wait, this has already been fixed in a223048

👀 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 #8724

@greg0ire
Copy link
Member

greg0ire commented Jun 9, 2021

Ah indeed, ManyToMany needs to be handled as well 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants