-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] Ignore when using #[Ignore] on a non-accessor #54485
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
Conversation
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); |
There was a problem hiding this comment.
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);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated to your suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
754463a
to
580b06a
Compare
Thank you @nicolas-grekas. |
Hello, Does this PR will be added in Thanks. |
@kl3sk it will be merged up to newer branch in the next merge up. |
@stof thank you, I'll wait for the next one. My app is partially broken '-_- |
@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). |
Ho thanks @stof , I was looking for a workaround. I manage to do it. |
Hello, When will this PR be merged into the SF 6.4., 7.0. and 7.1.* branches? |
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). |
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", |
Because ignore means ignore so we know what to do with the attribute even when it's on something else than an accessor.