[PR #917] [MERGED] DDC-2931 - one-to-one self-referencing association broken by DCOM-96 #8892

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

📋 Pull Request Information

Original PR: https://github.com/doctrine/orm/pull/917
Author: @Ocramius
Created: 1/24/2014
Status: Merged
Merged: 2/8/2014
Merged by: @beberlei

Base: masterHead: hotfix/DDC-2931


📝 Commits (8)

  • fabef48 [DDC-2931] testcase to reproduce Jira 2931
  • 22bcfef DDC-2931 - cleaning up code formatting/simplifying test case
  • 9eafb11 DDC-2931 - Detailed explanation
  • 596d207 DDC-2931 - Removing refresh hints when fetching association data in hydrators
  • b815a4b DDC-2931 - removing old comments
  • 8c92e0f DDC-2931 - adding test that verifies that fetch-joined entities get refreshed with hints
  • 7a32eca DDC-2931 - Safe comparison between proxies and entities when refreshing objects
  • e322ab4 DDC-2931 - Removing previous broken fix for DDC-2931 - hardened

📊 Changes

2 files changed (+155 additions, -3 deletions)

View changed files

📝 lib/Doctrine/ORM/UnitOfWork.php (+36 -3)
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php (+119 -0)

📄 Description

This is a hotfix for DDC-2931 ( #916 )

Background

After some debugging, I found that the issue came from UnitOfWork#createEntity with #406 (DCOM-96).

When initializing the proxy for $first (during the DDC2931User#getRank() call), the ORM attempts to fetch also $second again via ObjectHydrator#getEntity, but the hint doctrine.refresh.entity contains the initialized proxy, while the identifier passed down is the identifier of $second (not a proxy).

UnitOfWork#createQuery does some comparisons and detects the fact that the two objects don't correspond, and therefore marks the entity as "to be detached" (since it thinks that the one in the "refresh" hint is the correct entity to load).


🔄 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/917 **Author:** [@Ocramius](https://github.com/Ocramius) **Created:** 1/24/2014 **Status:** ✅ Merged **Merged:** 2/8/2014 **Merged by:** [@beberlei](https://github.com/beberlei) **Base:** `master` ← **Head:** `hotfix/DDC-2931` --- ### 📝 Commits (8) - [`fabef48`](https://github.com/doctrine/orm/commit/fabef48ca23391c32ff403417ad03c6be102fb21) [DDC-2931] testcase to reproduce Jira 2931 - [`22bcfef`](https://github.com/doctrine/orm/commit/22bcfef523f0768c9500571e42833cffb11a9931) DDC-2931 - cleaning up code formatting/simplifying test case - [`9eafb11`](https://github.com/doctrine/orm/commit/9eafb11a02afa493a9618b429966cb390a316b92) DDC-2931 - Detailed explanation - [`596d207`](https://github.com/doctrine/orm/commit/596d2070edcbba0e4ea863e134831380214377ab) DDC-2931 - Removing refresh hints when fetching association data in hydrators - [`b815a4b`](https://github.com/doctrine/orm/commit/b815a4b2d35f05bc15372a8aa39a4ff89b9ad706) DDC-2931 - removing old comments - [`8c92e0f`](https://github.com/doctrine/orm/commit/8c92e0f19fe47bea87af578f01fd80b81834f118) DDC-2931 - adding test that verifies that fetch-joined entities get refreshed with hints - [`7a32eca`](https://github.com/doctrine/orm/commit/7a32eca039e76e09d7e24aa53544991af39fc519) DDC-2931 - Safe comparison between proxies and entities when refreshing objects - [`e322ab4`](https://github.com/doctrine/orm/commit/e322ab4debf0fae1a8c4b9a1b30e336c991c701b) DDC-2931 - Removing previous broken fix for DDC-2931 - hardened ### 📊 Changes **2 files changed** (+155 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `lib/Doctrine/ORM/UnitOfWork.php` (+36 -3) ➕ `tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php` (+119 -0) </details> ### 📄 Description This is a hotfix for DDC-2931 ( #916 ) ### Background > After some debugging, I found that the issue came from [`UnitOfWork#createEntity`](https://github.com/doctrine/doctrine2/blob/bba5ec27fbbe35224be48878a0c92827ef2f9733/lib/Doctrine/ORM/UnitOfWork.php#L2512-L2528) with #406 ([DCOM-96](http://www.doctrine-project.org/jira/browse/DCOM-96)). > > When initializing the proxy for `$first` (during the `DDC2931User#getRank()` call), the ORM attempts to fetch also `$second` again via [`ObjectHydrator#getEntity`](https://github.com/doctrine/doctrine2/blob/bba5ec27fbbe35224be48878a0c92827ef2f9733/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php#L280), but the hint `doctrine.refresh.entity` contains the initialized proxy, while the identifier passed down is the identifier of `$second` (not a proxy). > > `UnitOfWork#createQuery` does some comparisons and detects the fact that the two objects don't correspond, and therefore marks the entity as "to be detached" (since it thinks that the one in the "refresh" hint is the correct entity to load). --- <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:02:10 +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#8892