Closed Steveb-p closed 5 months ago
see #54804
Thank you very much @xabbuh for looking into it :bow:
Will this be available in 7.0.* ?
Yes, bugfix will be part of the next patch releases for Symfony 5.4, 6.4 and 7.0.
And for the 3rd time for me, rollback to v6.4.3
Symfony version(s) affected
5.4.39, 6.4.7, 7.0.7
Description
In the following commit, a change was introduced to the
ObjectNormalizer
constructor signature. https://github.com/symfony/symfony/commit/900d034003875d16aa7b5a293be82a9fd932c681Now,
ObjectNormalizer
requiresPropertyInfoExtractorInterface
to be passed as last argument (or anull
value). This is aliased in framework to matchproperty_info
service. https://github.com/symfony/symfony/blob/c168c2c137acee438463fcde2df1685cf74ff623/src/Symfony/Bundle/FrameworkBundle/Resources/config/property_info.php#L33So, under normal circumstances in an application that uses Symfony framework, this is filled with
PropertyInfoExtractorInterface
(when autowiring, for example).If
null
value is passed,ReflectionExtractor
object is created in it's stead. https://github.com/symfony/symfony/blob/c168c2c137acee438463fcde2df1685cf74ff623/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php#L53However,
ReflectionExtractor
is not a representation ofPropertyInfoExtractorInterface
. https://github.com/symfony/symfony/blob/c168c2c137acee438463fcde2df1685cf74ff623/src/Symfony/Component/PropertyInfo/Extractor/ReflectionExtractor.php#L39On the following line: https://github.com/symfony/symfony/blob/c168c2c137acee438463fcde2df1685cf74ff623/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php#L177-L178 ...the property that can contain either
PropertyInfoExtractorInterface
orReflectionExtractor
is used - a methodgetWriteInfo()
is called that exists only onReflectionExtractor
. This means thatPropertyInfoExtractorInterface
cannot be used and will cause a PHP error, which results in inability to denormalize that object.Ergo, in case of our app, we cannot use the
property_info
service (nor it's caching), and must fall back tonull
.How to reproduce
We have this error...
...happen when
ObjectNormalizer
is asked to denormalize an object of the following type:with data (partial extract):
The
ObjectNormalizer
service is defined as follows:Possible Solution
ObjectNormalizer
, in lieu of addingPropertyInfoExtractorInterface
toReflectionExtractor
, should perform checks against method presence to better inform developers about what is actually going on and/or a fallback should exist in cases where we are not dealing withReflectionExtractor
instance.Additional Context
No response