You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a class has a method called get that method will get confused for an accessor and it will go through logic relating to property-access for the property named substr('get', 3).
Eventually a new PropertyPath instance will be created with an empty path which will trigger an exception.
mihai-stancu
changed the title
ObjectNormalizer throws exception normalizing classes with the method get
[Serializer] ObjectNormalizer throws exception normalizing classes with the method getAug 24, 2024
This PR was squashed before being merged into the 6.4 branch.
Discussion
----------
[Serializer] Fix for method named `get()`
| Q | A
| ------------- | ---
| Branch? | 6.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues | Fix#58012
| License | MIT
During normalization, if a class has a method called `get` that method will get confused for an accessor and it will go through logic relating to property-access for the property named `substr('get', 3)`.
Eventually a new PropertyPath instance will be created with an empty path which will trigger an exception.
```php
$serializer->serialize(new class {
public function get() {}
}, 'json');
```
Commits
-------
a0d6e26 [Serializer] Fix for method named `get()`
Symfony version(s) affected
>= 6.4.x
Description
If a class has a method called
get
that method will get confused for an accessor and it will go through logic relating to property-access for the property namedsubstr('get', 3)
.Eventually a new
PropertyPath
instance will be created with an empty path which will trigger an exception.How to reproduce
Possible Solution
A naive solution
ObjectNormalizer::isAllowedAttribute()
at line 193But most likely this object would need to be skipped earlier in the normalization process, perhaps here:
Additional Context
Exception is triggered around here
$propertyAccessor->isReadable()
instantiates aPropertyPath
.The text was updated successfully, but these errors were encountered: