[Bug] Attempting to change readonly property when removing an entity #6987

Closed
opened 2026-01-22 15:42:41 +01:00 by admin · 1 comment
Owner

Originally created by @pattisahusiwa on GitHub (Jun 3, 2022).

Bug Report

Q A
BC Break no
Version 2.12.2
PHP 8.1.6

Summary

When removing an entity with read-only $id, \LogicException is thrown

Current behavior

\LogicException is thrown

bug

How to reproduce

#[ORM\Entity]
class Entity
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column(type: 'integer')]
    public readonly int $id;
}
$em->remove($entity);
$em->flush();

Expected behavior

No error.

Originally created by @pattisahusiwa on GitHub (Jun 3, 2022). ### Bug Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | BC Break | no | Version | 2.12.2 | PHP | 8.1.6 #### Summary <!-- Provide a summary describing the problem you are experiencing. --> When removing an entity with read-only `$id`, `\LogicException` is thrown #### Current behavior <!-- What is the current (buggy) behavior? --> `\LogicException` is thrown ![bug](https://user-images.githubusercontent.com/11484016/171938422-43cc07d6-f3a4-46fe-881f-a8593e760442.png) #### How to reproduce <!-- Provide steps to reproduce the bug. If possible, also add a code snippet with relevant configuration, entity mappings, DQL etc. Adding a failing Unit or Functional Test would help us a lot - you can submit one in a Pull Request separately, referencing this bug report. --> ```php #[ORM\Entity] class Entity { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column(type: 'integer')] public readonly int $id; } ``` ```php $em->remove($entity); $em->flush(); ``` #### Expected behavior <!-- What was the expected (correct) behavior? --> No error.
admin closed this issue 2026-01-22 15:42:41 +01:00
Author
Owner

@greg0ire commented on GitHub (Jun 3, 2022):

Duplicate of #9538

@greg0ire commented on GitHub (Jun 3, 2022): Duplicate of #9538
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6987