Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore on ProxyClass__setInitialized() cannot be added

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?

like image 486
Jan Doornbos Avatar asked Mar 31 '26 22:03

Jan Doornbos


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 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"

like image 191
Victor T. Avatar answered Apr 02 '26 11:04

Victor T.


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"
like image 21
Cellophile Avatar answered Apr 02 '26 10:04

Cellophile



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!