Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[FrameworkBundle] avoid issue with doctrine/annotations 2.0.0 #48868

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

Conversation

alexislefebvre
Copy link
Contributor

@alexislefebvre alexislefebvre commented Jan 4, 2023

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #48792
License MIT
Doc PR no

Switching from doctrine/annotations 1 to 2 break some apps, here is a reproducer with an empty Controller: #48792 (comment)

I don't know how to add a test about this, but here is the fix suggested by the error message and greg0ire in doctrine/annotations#474 (comment)

@carsonbot carsonbot added this to the 5.4 milestone Jan 4, 2023
@alexislefebvre alexislefebvre force-pushed the 5.4-avoid-issue-with-doctrine/annotations-2.0.0 branch 2 times, most recently from a135dac to fa56fb5 Compare January 4, 2023 11:17
@alexislefebvre alexislefebvre force-pushed the 5.4-avoid-issue-with-doctrine/annotations-2.0.0 branch from fa56fb5 to 2ecb4c6 Compare January 4, 2023 11:21
@alexislefebvre alexislefebvre changed the title avoid issue with doctrine/annotations 2.0.0 [FrameworkBundle] avoid issue with doctrine/annotations 2.0.0 Jan 4, 2023
@@ -53,6 +54,10 @@
* Provides shortcuts for HTTP-related features in controllers.
*
* @author Fabien Potencier <[email protected]>
*
* The following annotation is necessary for compatibility with doctrine/annotations:^2.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need that comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only instance of @IgnoreAnnotation in the codebase, so I added that for future developers which may be surprised, and removing it won't break the tests so it may be removed by mistake.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please see my comment below to actually investigate the root cause of why this fails with doctrine/annotations 2.0 but not with doctrine/annotations 1.14 as this either indicates an undocumented BC break or a bug.

@stof
Copy link
Member

stof commented Jan 4, 2023

This looks weird to me, because we still configure our annotation reader with a call ->addGlobalIgnoreName('required'). so this should be unnecessary (otherwise, it indicates a BC break in doctrine/annotations 2.0 that is not described in their upgrade file)

@alexislefebvre
Copy link
Contributor Author

alexislefebvre commented Jan 5, 2023

Commenting service('annotations.dummy_registry')->ignoreOnInvalid(), fixes the issue with the reproducer.

I don't understand the role of this line, it looks like it provides 2 arguments but addGlobalIgnoredName only accept one.

@Jeroeny
Copy link
Contributor

Jeroeny commented Jan 6, 2023

we still configure our annotation reader with a call ->addGlobalIgnoreName('required')

Where could I find this line of code? I'd like to debug it as I'm also running into this bug.

@alexislefebvre
Copy link
Contributor Author

Where could I find this line of code? I'd like to debug it as I'm also running into this bug.

There was a typo, a d was missing, here is what you're looking for: https://github.com/symfony/symfony/search?q=addGlobalIgnoredName

@alexislefebvre
Copy link
Contributor Author

#48874 is a cleaner way to fix this issue.

@stof
Copy link
Member

stof commented Jan 6, 2023

the alternative PR is indeed a clean way to fix that particular error. But my comment in #48868 (comment) still holds true. It would be great to check whether doctrine/annotations contains an undocumented BC break, a bug or whether our doctrine/annotations 2.0 support has a bug. Otherwise, other packages might trigger a similar bug.

@alexislefebvre
Copy link
Contributor Author

@stof I'm pretty sure that the issue comes from Symfony, it looks like that in some cases addGlobalIgnoredName is not called, see this comment: #48868 (comment)

@fabpot fabpot closed this Jan 7, 2023
fabpot added a commit that referenced this pull request Jan 7, 2023
…ibute (alexislefebvre)

This PR was merged into the 6.3 branch.

Discussion
----------

[FrameworkBundle] remove double required annotation + attribute

| Q             | A
| ------------- | ---
| Branch?       | 6.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #48792 (checked with [this reproducer](#48792 (comment)))
| License       | MIT
| Doc PR        | no

Annotation and attribute were kept: #45680 (comment)

To my understanding, it's not necessary since #48810

Alternative to #48868

Commits
-------

8e8772d remove double required annotation + attribute
@alexislefebvre alexislefebvre deleted the 5.4-avoid-issue-with-doctrine/annotations-2.0.0 branch January 7, 2023 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants