mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Attempts to change readonly Id when generation strategy is NONE #6912
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 @theMadness on GitHub (Jan 24, 2022).
Bug Report
Summary
When persisting an entity with a NONE generation strategy and a readonly id property, a Logic Exception is thrown due to attempts to change the id value.
Current behavior
LogicException is thrown.
The last parts of the stack are
UnitOfWork->persistNew
ClassMetadataInfo->setIdentifierValues
ReflectionReadonlyProperty->setValue
How to reproduce
Attempt to persist an entity with a readonly (as in public readonly int $id) id without any GeneratedValue strategy.
Expected behavior
Normally persisted entity.
@beberlei commented on GitHub (Jan 24, 2022):
This can't really be, when you use the "NONE" identify generator, then
persistNewdoes not callsetIdentifierValues:6d5da83c68/lib/Doctrine/ORM/UnitOfWork.php (L991)Could you investiagte a little more? Post the mapping exception message and the full stack trace please
@theMadness commented on GitHub (Jan 24, 2022):
Will do as soon as I can, thank you for the very quick reply.