mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Deleting an entity with hooked identifier property on PHP 8.4 throws an error #7533
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @CiBeRHeMuL on GitHub (Jul 17, 2025).
Bug Report
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 and delete entity
@BusterNeece commented on GitHub (Jul 18, 2025):
Can confirm the same issue is present when hydrating lazy collections with hooked properties whose values are
null. The property accessor is trying to unset them, which it no longer can do with hooked properties:e714b1a2fc/src/Mapping/PropertyAccessors/TypedNoDefaultPropertyAccessor.php (L43-L45)@abramchikd commented on GitHub (Aug 17, 2025):
I have the same issue
@flow38 commented on GitHub (Nov 12, 2025):
Same problem here, a quick fix is to make your hook property nullable:
public MyType $data { set => $this->data = someAationOnValue($value)); }Become
public ?MyType $data { set => $this->data = someAationOnValue($value)); }