Skip to content

[VarExporter] Mapping Expception - Ignore can only be added on methods beginning with "get", "is", "has" or "set".` #54477

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

Closed
sgloe opened this issue Apr 3, 2024 · 11 comments

Comments

@sgloe
Copy link

sgloe commented Apr 3, 2024

Symfony version(s) affected

6.4.6

Description

After upgrading symfony/var-exporter from 6.4.4 to 6.4.6 I get an error during my serialization process.

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

vendor/symfony/serializer/Mapping/Loader/AttributeLoader.php:172

How to reproduce

Use Serializer and serialize some objects with relations and setting the context.

Possible Solution

No response

Additional Context

No response

@nicolas-grekas
Copy link
Member

Can you please send a PR to remove the annotation where it shouldn't be found?

@Gemorroj
Copy link
Contributor

Gemorroj commented Apr 3, 2024

same issue. new release (7.0.6) completely broke website

@jkgroupe
Copy link

jkgroupe commented Apr 3, 2024

Same here, I was creating an issue but you were faster than me and you found the issue origin

I downgraded from Symfony 6.4.6 to 6.4.5

composer.json

"symfony": {
      "allow-contrib": false,
      "require": "6.4.*, !=6.4.6"
}

Gemorroj added a commit to Gemorroj/magazine that referenced this issue Apr 3, 2024
@eisberg
Copy link

eisberg commented Apr 3, 2024

This PR breaks: #54224

Ignore attribute in file src/Symfony/Component/VarExporter/LazyGhostTrait.php

 #[Ignore]
    private function setLazyObjectAsInitialized(bool $initialized): void
    {

@xabbuh
Copy link
Member

xabbuh commented Apr 3, 2024

I fail to see why the Ignore attribute on setLazyObjectAsInitialized() should be the culprit as that method follows the pattern the AttributeLoader accepts for an accessor or mutator.

Can anyone affected by this bug please create a small example application that allows to reproduce it?

@nicolas-grekas
Copy link
Member

That's because Doctrine is aliasing this method to another name.

@nicolas-grekas
Copy link
Member

setLazyObjectAsInitialized as public __setInitialized;

@99hops
Copy link

99hops commented Apr 3, 2024

I just saw the same issue 6.4.5 works fine.

@fabpot fabpot closed this as completed Apr 5, 2024
fabpot added a commit that referenced this issue Apr 5, 2024
… (nicolas-grekas)

This PR was merged into the 5.4 branch.

Discussion
----------

[Serializer] Ignore when using #[Ignore] on a non-accessor

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #54477
| License       | MIT

Because ignore means ignore so we know what to do with the attribute even when it's on something else than an accessor.

Commits
-------

580b06a [Serializer] Ignore when using #[Ignore] on a non-accessor
@Josee9988
Copy link

Same here with symfony 7.0.6

@sebheitzmann
Copy link

I have the same problem in a MessageHandler.
Why it this issue closed ?

@xabbuh
Copy link
Member

xabbuh commented Apr 8, 2024

@sebheitzmann The PR fixing this issue (#54485) has been merged and will be part of the next patch releases.

@symfony symfony locked as resolved and limited conversation to collaborators Apr 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests