Skip to content

[PropertyAccess] Class property ignored when unrelated methods are marked as ignored instead #45016

@Jeroeny

Description

@Jeroeny

Symfony version(s) affected

6.*

Haven't checked any older versions.

Description

Given I have a class like:

abstract class Bad
{
    #[Ignore]
    private bool $create = false;

    #[Ignore]
    private bool $delete = false;

    private Uuid $id;

    public function __construct(Uuid $id)
    {
        $this->id = $id;
    }

...
$this->serializer->serialize(new BadOne(Uuid::v4()),'json'); 
// returns: {"foo":"foo"}
// expected: {"foo":"foo","id":"597eb634-7aff-4513-ba1c-c928e01ff60c"}

Now when a child class is (de)serialized, the id property is marked as ignored and not included in the output. The linked reproducer should give some more details.

This could be a fairly critical bug in some cases, because if the serializer is user for DB entities, values can be lost.

How to reproduce

https://github.com/Jeroeny/reproduce/tree/annotate

Possible Solution

No response

Additional Context

No response

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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy