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] Prevent GetSetMethodNormalizer
from creating invalid magic method call
#48233
[Serializer] Prevent GetSetMethodNormalizer
from creating invalid magic method call
#48233
Conversation
GetSetMethodNormalizer
from creating invalid magic method call
src/Symfony/Component/Serializer/Tests/Normalizer/GetSetMethodNormalizerTest.php
Outdated
Show resolved
Hide resolved
b9f462a
to
11f49bf
Compare
Should the |
@xabbuh denormalization does not seem to be affected. |
Doe we have a test case for this? Otherwise it could be helpful to add one in this PR |
11f49bf
to
4a34485
Compare
I was wrong! Good catch @xabbuh. Managed to reproduce it, but had to take a different approach: |
4a34485
to
adbb96f
Compare
adbb96f
to
d4e1edd
Compare
Thank you @klaussilveira. |
When serializing an object that has an
isser
for a property, but not agetter
, and the object happens to have a__call
magic method, theGetSetMethodNormalizer
will attempt to call the magic method with the attribute. This may cause unexpected behavior, or, a fatal. It depends on the__call
implementation.This undefined behavior is caused by the use of
is_callable
ongetAttributeValue
, which will return true since there is a__call
implementation. The correct behavior can be achieved by usingmethod_exists
instead. A test case has been added that illustrates the issue.