[PR #12335] [MERGED] Avoid lazy object initialization when initializing read-only property #13701

Closed
opened 2026-01-22 16:18:11 +01:00 by admin · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/doctrine/orm/pull/12335
Author: @greg0ire
Created: 1/6/2026
Status: Merged
Merged: 1/9/2026
Merged by: @greg0ire

Base: 3.6.xHead: gh-12166


📝 Commits (1)

  • e923bbc Avoid lazy object initialization when initializing read-only property

📊 Changes

3 files changed (+83 additions, -1 deletions)

View changed files

📝 src/Mapping/PropertyAccessors/ReadonlyAccessor.php (+8 -1)
tests/Tests/ORM/Functional/Ticket/GH12166/GH12166Test.php (+32 -0)
tests/Tests/ORM/Functional/Ticket/GH12166/LazyEntityWithReadonlyId.php (+43 -0)

📄 Description

Initializing e.g. a readonly ID does not require loading any data from
the database. However, calling isInitialized() on the reflection of a
readonly property triggers the native lazy object initialization.
If we have a lazy property at hand, then the property cannot be initialized
already, so it is safe to skip the call.

Fixes #12166


🔄 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/12335 **Author:** [@greg0ire](https://github.com/greg0ire) **Created:** 1/6/2026 **Status:** ✅ Merged **Merged:** 1/9/2026 **Merged by:** [@greg0ire](https://github.com/greg0ire) **Base:** `3.6.x` ← **Head:** `gh-12166` --- ### 📝 Commits (1) - [`e923bbc`](https://github.com/doctrine/orm/commit/e923bbc93222968d65d9490964eaff257b075a19) Avoid lazy object initialization when initializing read-only property ### 📊 Changes **3 files changed** (+83 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/Mapping/PropertyAccessors/ReadonlyAccessor.php` (+8 -1) ➕ `tests/Tests/ORM/Functional/Ticket/GH12166/GH12166Test.php` (+32 -0) ➕ `tests/Tests/ORM/Functional/Ticket/GH12166/LazyEntityWithReadonlyId.php` (+43 -0) </details> ### 📄 Description Initializing e.g. a readonly ID does not require loading any data from the database. However, calling isInitialized() on the reflection of a readonly property triggers the native lazy object initialization. If we have a lazy property at hand, then the property cannot be initialized already, so it is safe to skip the call. Fixes #12166 --- <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:18:11 +01:00
admin closed this issue 2026-01-22 16:18:12 +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#13701