Skip to content

[ObjectMapper] Cannot unset hooked property #60982

Closed
@tacman

Description

@tacman

Symfony version(s) affected

7.3.1

Description

Although there are a few issues references earlier versions of Symfony, (e.g. #59153) this is failing for me when using ObjectMapper.

How to reproduce

class Instrument
{
    public function __construct(
        #[ORM\Id]
        #[ORM\Column]
        private(set) ?string $id, // probably uuid

        #[ORM\Column(type: Types::JSON, options: ['jsonb' => true], nullable: true)]
        private(set) array $genres {
            set => self::cleanupGenres($value);
        }

    )
    {

    }

The load command, using ObjectMapper

        $objectMapper = new ObjectMapper();
        $count = 0;
        while ($data = $ndjson->readline()) {
            $existing = $instrumentRepo->find($data->id);
            try {
                $obj = $objectMapper->map($data, $existing ?? $class);
                $this->entityManager->persist($obj);
            } catch (\Exception $e) {
                dump($data);
                die($e->getMessage());
            }

at /home/tac/g/sites/dt-demo/vendor/doctrine/orm/src/Mapping/PropertyAccessors/TypedNoDefaultPropertyAccessor.php:44
App\Entity\Instrument->{closure:Doctrine\ORM\Mapping\PropertyAccessors\TypedNoDefaultPropertyAccessor::setValue():43}() at /home/tac/g/sites/dt-demo/vendor/doctrine/orm/src/Mapping/PropertyAccessors/TypedNoDefaultPropertyAccessor.php:52
Doctrine\ORM\Mapping\PropertyAccessors\TypedNoDefaultPropertyAccessor->setValue() at /home/tac/g/sites/dt-demo/vendor/doctrine/orm/src/UnitOfWork.php:2411
Doctrine\ORM\UnitOfWork->createEntity() at /home/tac/g/sites/dt-demo/vendor/doctrine/orm/src/Internal/Hydration/SimpleObjectHydrator.php:176
Doctrine\ORM\Internal\Hydration\SimpleObjectHydrator->hydrateRowData() at /home/tac/g/sites/dt-demo/vendor/doctrine/orm/src/Internal/Hydration/SimpleObjectHydrator.php:60
Doctrine\ORM\Internal\Hydration\SimpleObjectHydrator->hydrateAllData() at /home/tac/g/sites/dt-demo/vendor/doctrine/orm/src/Internal/Hydration/AbstractHydrator.php:171
Doctrine\ORM\Internal\Hydration\AbstractHydrator->hydrateAll() at /home/tac/g/sites/dt-demo/vendor/doctrine/orm/src/Persisters/Entity/BasicEntityPersister.php:754
Doctrine\ORM\Persisters\Entity\BasicEntityPersister->load() at /home/tac/g/sites/dt-demo/vendor/doctrine/orm/src/Persisters/Entity/BasicEntityPersister.php:764
Doctrine\ORM\Persisters\Entity\BasicEntityPersister->loadById() at /home/tac/g/sites/dt-demo/vendor/doctrine/orm/src/EntityManager.php:362

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