[PR #12229] Reorganize read-only class check in UnitOfWork #13600

Open
opened 2026-01-22 16:17:43 +01:00 by admin · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/doctrine/orm/pull/12229
Author: @rvanlaak
Created: 10/20/2025
Status: 🔄 Open

Base: 2.20.xHead: patch-1


📝 Commits (3)

📊 Changes

2 files changed (+33 additions, -6 deletions)

View changed files

📝 src/UnitOfWork.php (+9 -5)
📝 tests/Tests/ORM/UnitOfWorkTest.php (+24 -1)

📄 Description

Right now, calling computeChangeSets and thereafter trying to rely on isReadOnly does not work as expected. The state of readOnlyObjects internally did not sufficiently get updated. Thereby public method isReadOnly is not as reliable as expected.

This PR moves the check for read-only classes to a different location in the code to improve reliability of isReadOnly.

Taking the metadata to userland in order to check for a class to be readonly is not preferable, especially as computeChangeSets already is iterating over the metadata and entity objects.

Expected behavior

Being able to reliably use isReadOnly to throw an exception in userland when a write to an entity is expected while these values won't be committed / flushed by the orm.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/doctrine/orm/pull/12229 **Author:** [@rvanlaak](https://github.com/rvanlaak) **Created:** 10/20/2025 **Status:** 🔄 Open **Base:** `2.20.x` ← **Head:** `patch-1` --- ### 📝 Commits (3) - [`403fb38`](https://github.com/doctrine/orm/commit/403fb38b3fea60ca6915ad42431a0d2dd8969cc3) Reorganize read-only class check in UnitOfWork - [`0edc467`](https://github.com/doctrine/orm/commit/0edc4675af1e4be09d84927c3edf996377327f1b) Add test on what to expect - [`6da8329`](https://github.com/doctrine/orm/commit/6da8329e633a8c4f75f4665da4f77d216187570c) cs ### 📊 Changes **2 files changed** (+33 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `src/UnitOfWork.php` (+9 -5) 📝 `tests/Tests/ORM/UnitOfWorkTest.php` (+24 -1) </details> ### 📄 Description Right now, calling `computeChangeSets` and thereafter trying to rely on `isReadOnly` does not work as expected. The state of `readOnlyObjects` internally did not sufficiently get updated. Thereby public method `isReadOnly` is not as reliable as expected. This PR moves the check for read-only classes to a different location in the code to improve reliability of `isReadOnly`. Taking the metadata to userland in order to check for a class to be readonly is not preferable, especially as `computeChangeSets` already is iterating over the metadata and entity objects. ## Expected behavior Being able to reliably use `isReadOnly` to throw an exception in userland when a write to an entity is expected while these values won't be committed / flushed by the orm. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
admin added the pull-request label 2026-01-22 16:17:43 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#13600