Skip to content
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

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

Merged
merged 1 commit into from Apr 5, 2024

Conversation

nicolas-grekas
Copy link
Member

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.

@xabbuh
Copy link
Member

xabbuh commented Apr 4, 2024

looks like the check was added on purpose (see #45016)

if (!$accessorOrMutator) {
throw new MappingException(sprintf('Ignore on "%s::%s()" cannot be added. Ignore can only be added on methods beginning with "get", "is", "has" or "set".', $className, $method->name));
}

$attributeMetadata->setIgnore(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe silently ignoring the attribute on non-accessor and non-mutator methods can help:

if ($accessorOrMutator) {
    $attributeMetadata->setIgnore(true);
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated to your suggestion

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jeroeny could you please check if this works with #45016 in mind?

@fabpot
Copy link
Member

fabpot commented Apr 5, 2024

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 22e9fd1 into symfony:5.4 Apr 5, 2024
9 of 12 checks passed
@kl3sk
Copy link

kl3sk commented Apr 5, 2024

Hello,

Does this PR will be added in 7 branch too ? (7.0.6 actually)
I have the same issue that looks to be fixed with this PR

Thanks.

@stof
Copy link
Member

stof commented Apr 5, 2024

@kl3sk it will be merged up to newer branch in the next merge up.

@kl3sk
Copy link

kl3sk commented Apr 5, 2024

@stof thank you, I'll wait for the next one. My app is partially broken '-_-

@stof
Copy link
Member

stof commented Apr 5, 2024

@kl3sk the workaround is to downgrade symfony/var-exporter to the previous version to avoid using the broken 7.0.6 version (as that's the only version of 7.0.x containing the regression).

@kl3sk
Copy link

kl3sk commented Apr 5, 2024

Ho thanks @stof , I was looking for a workaround. I manage to do it.

@ValentinRgt
Copy link

Hello,

When will this PR be merged into the SF 6.4., 7.0. and 7.1.* branches?
If possible have an approximate date

@xabbuh
Copy link
Member

xabbuh commented Apr 26, 2024

It's already present in all maintained branches. Patch releases do happen once a month (so probably at the end of April or the beginning of May).

@derrabus
Copy link
Member

Locking to prevent further "why isn't this fixed yet?!" comments.

Please wait for the next release. If you want to check if the next release will actually fix your problem, you can do so by allowing Composer to install a dev snapshot.

Symfony 5.4

"symfony/serializer": "~5.4.39@dev",

Symfony 6.4

"symfony/serializer": "~6.4.7@dev",

Symfony 7.0

"symfony/serializer": "~7.0.7@dev",

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

Successfully merging this pull request may close these issues.

None yet

9 participants