-
|
I have tried to upgrade my Symfony example project https://github.com/hantsy/symfony-rest-sample to v8.0, there is a test failed due to error like this. https://github.com/hantsy/symfony-rest-sample/actions/runs/19756748559/job/56609665804#step:11:29 {"error":"A circular reference has been detected when serializing the object of
class \u0022App\\Entity\\Comment\u0022 (configured limit: 1)."}The But on the #[Entity(repositoryClass: CommentRepository::class)]
class Comment
{
// ...
#[ManyToOne(targetEntity: "Post", inversedBy: "comments")]
#[JoinColumn(name: "post_id", referencedColumnName: "id")]
#[Ignore]
private Post $post;The codes worked since Symfony v5.x - 7.3, but failed when upgrading v8.0. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Beta Was this translation helpful? Give feedback.
-
|
@hantsy doesn't exist anymore in 8.0 symfony/src/Symfony/Component/Serializer/Attribute/Ignore.php Lines 12 to 18 in 32f6f6c in <= 7.4 there was a fallback from Annotation to Attributes that got removed with 8.0 |
Beta Was this translation helpful? Give feedback.
@hantsy
https://github.com/hantsy/symfony-rest-sample/blob/15843a0c5b7a93b3d00a903045a434cd775ed636/src/Entity/Comment.php#L17
use Symfony\Component\Serializer\Annotation\Ignore;doesn't exist anymore in 8.0
because they are not Annotations, but Attributes:
symfony/src/Symfony/Component/Serializer/Attribute/Ignore.php
Lines 12 to 18 in 32f6f6c
in <= 7.4 there was a fallback from Annotation to Attributes that got removed with 8.0