Ignore on ProxyClass__setInitialized() cannot be added
Asked Answered
P

2

11

I'm trying to update to Symfony 7.0. So far the update was successful. Now, when I try to call one of my endpoints I get the following error:

"Ignore on \"Proxies\\__CG__\\App\\Entity\\Role::__setInitialized()\" cannot be added. Ignore can only be added on methods beginning with \"get\", \"is\", \"has\" or \"set\"."

The endpoint loads the User entities from Doctrine via the UserRepository. There is no custom query, just the simple findBy function is used. The Role is an associated relationship. I don't use the #[Ignore] attribute anywhere in my code.

The version of Symfony is 7 and I have Doctrine 3.0. I did some research and found that in the LazyGhostTrait.php file there is an #[Ignore]. So this class is probably causing the issue?

Is this a bug in Symfony or do I need some additional configuration somewhere?

Prearrange answered 6/4, 2024 at 17:45 Comment(2)
You can follow the github's symfony issue which is closed. I created a new one with the new Symfony version hereRelict
Thanks. I couldn’t find an issue yesterday. I see that more people have this issue with 7.0.6. Hopefully they fix it soon.Prearrange
B
12

2024-04-29 EDIT: Symfony solved the issue for problematic package symfony/var-exporter. Upgrade to version ^7.0.7 or ^6.4.7 depending on your Symfony version to get rid of the bug.


As pointed out by Jose9988, this is a bug in Symfony, and more precisely by version 7.0.6 of symfony/var-exporter package. A PR fixing this issue has been merged and will be part of the next patch releases.

In the meantime, just downgrade symfony/var-exporter to version 7.0.4 with composer require "symfony/var-exporter:7.0.4"

Edit : for users using Symfony 6.4, the bug was introduced in version 6.4.6, so just composer require "symfony/var-exporter:6.4.5"

Biondo answered 9/4, 2024 at 15:50 Comment(1)
In my case I had to use symfony 7.0.* and var exporter in 6.4.0 due to some dependencies. But it worked.Relict
N
2

Review of 30/04/2024 : The new version of symfony/var-exporter (7.0.7) doesn't solve the problem at all.

We must continue to use the 7.0.4 version :

composer require "symfony/var-exporter=7.0.4"
Noncooperation answered 30/4, 2024 at 8:3 Comment(2)
It should not be the case. On Symfony's side, the issue has been solved, merged and published in version 7.0.7. If you still have the issue with version 7.0.7, maybe you are facing another issue, and it would be helpful to open a ticket.Biondo
Hello @VictorT., unfortunately, this is still the case, and on many of projects, for all of my students. On api routes, if they want to get some resources with repositories and groups, if they want to get collections, for some of those, there is this bug. The onlu solution I have found to let us get those collections is to downgrade var-exporter.Noncooperation

© 2022 - 2025 — McMap. All rights reserved.