doctrine-website icon indicating copy to clipboard operation
doctrine-website copied to clipboard

Update `2022-01-11-orm-2.11.md` to be clear about some limitations over "Support for Readonly Properties"

Open n4huel opened this issue 1 year ago • 3 comments

The support for read only properties only works fine for entities which use the "None" strategy for identifier generator. When the entity use other strategy, like the suggested in the documentation, an exception is thrown when you try to remove the entity.

See:

  • https://github.com/doctrine/orm/issues/10032
  • https://github.com/doctrine/orm/blob/2.14.x/lib/Doctrine/ORM/UnitOfWork.php#L1271-L1273
  • https://github.com/doctrine/orm/blob/2.14.x/lib/Doctrine/ORM/Mapping/ReflectionReadonlyProperty.php#L46
  • https://www.php.net/manual/en/language.oop5.properties.php#language.oop5.properties.readonly-properties
  • https://3v4l.org/FrhLN

n4huel avatar Apr 17 '23 18:04 n4huel

Hi @n4huel, and thank you for your contribution. This is a blog post from January 2022 about ORM 2.11. I don't know if an old blog post is supposed to be changed.

@beberlei how do you see it? should we adapt an old blog post? I'm asking you because this is one you've created.

SenseException avatar Apr 17 '23 19:04 SenseException

Thanks you @SenseException, your point is accurate. Maybe it should include some note/disclaimer update as "errata" since the feature isn't really supported.

n4huel avatar Apr 19 '23 18:04 n4huel

"it will not work" is also limited to the id field. Other fields can still be readonly.

stof avatar Aug 23 '23 17:08 stof