-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Deleting an entity with hooked identifier property on PHP 8.4 throws an error #12077
Copy link
Copy link
Open
Labels
Description
Bug Report
| Q | A |
|---|---|
| Version | 3.5.0 |
Summary
Deleting an entity with hooked identifier property on PHP 8.4 throws an error "Cannot unset hooked property EntityClass::$id"
Current behavior
After deleting entity from database Doctrine trying to unset identifier property on entity object, but if identifier property has hook PHP throws an error, because unsetting property with hook does not supported
Expected behavior
Doctrine delete an entity with hooked identifier property successfully
How to reproduce
- Create an entity with hooked identifier property
<?php
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity]
#[ORM\Table('entity')]
class Entity
{
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(UuidGenerator::class)]
#[ORM\Column(type: 'uuid', nullable: false)]
public Uuid $id {
get => $this->id;
set => $this->id = $value;
}
}Create and delete entity
<?php
$entity = new Entity();
$em->persist($entity);
$em->flush();
$em->remove($entity);
$em->flush(); // An exception is thrown hereReactions are currently unavailable