Skip to content

Conversation

n4huel
Copy link

@n4huel n4huel commented Apr 17, 2023

@SenseException
Copy link
Member

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.

@n4huel
Copy link
Author

n4huel commented Apr 19, 2023

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

@stof
Copy link
Member

stof commented Aug 23, 2023

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

@Novynn
Copy link

Novynn commented Jun 10, 2025

Doctrine ORM still does not support readonly ids due to this problem, and the blog post is the first thing that appears in a search.

@vuryss
Copy link

vuryss commented Sep 15, 2025

Just found another bug with the readonly IDs and new PHP 8.4 ghost objects - if the ID is readonly of a related entity - when it tries to create a proxy for that related entity - the proxy is immediately initialized from the ReadonlyAccessor - it calls the reflection property->isInitialized on the ID and this triggers the initialization in the foreach right after the proxy generation. Here is the stacktrace from inside of the ghost object function to visualize which flow triggered the initialization.

image

This cascades to a very ugly and hard to trace bug - it sets the originalEntityData to empty array, which then behind the scenes ignores all changes made on that entity on flush. Just spent like 3 hours debugging to find that out. Also couldn't use debugger to trace that issue, because the xdebug itself triggers the initialization of entities so manual logs until my head spins..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants