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?
2
Answers
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 withcomposer 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"
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 :