Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Serializer] All fields are not included by default, but upon adding any attribute, all fields are then required #52673

Closed
@nesl247

Description

@nesl247

Symfony version(s) affected

6.3.8

Description

According to https://symfony.com/doc/current/components/serializer.html#ignoring-attributes all properties are included by default, which makes sense. However, this doesn't seem to be the case at least for traits and abstract classes.

When we don't add the #[Ignore] attribute in the TestTrait in the reproducer, everything works fine. However, adding that attribute causes all of the other properties to now be seen by the serializer and then fail because there is no public access to them via getters or via public properties.

How to reproduce

https://github.com/nesl247/symfony-serialization-ignore-bug

  1. git clone https://github.com/nesl247/symfony-serialization-ignore-bug.git
  2. composer install
  3. bin/console test:command

Possible Solution

No response

Additional Context


In PropertyAccessor.php line 456:
                                                                                    
  Can't get a way to read the property "testProperty2" in class "App\TestMessage".  
                                                                                    

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions