forked from doctrine/orm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
From f4432f484544a2fbd867a52b734dac63016480d5 Mon Sep 17 00:00:00 2001 | ||
From: Tom Udding <[email protected]> | ||
Date: Fri, 18 Oct 2024 11:51:54 +0200 | ||
Subject: [PATCH 1/1] Revert "Fix lazy loading of 1-to-1 relationship with | ||
custom id object" | ||
|
||
This reverts a small change to `Doctrine\ORM\Persisters\Entity\BasicEntityPersister` | ||
which caused one-to-one relations with an `JoinColumns` annotation to break. | ||
--- | ||
.../Entity/BasicEntityPersister.php | 22 +++++++++++++++++-- | ||
.../ORM/Functional/Ticket/GH5887Test.php | 2 ++ | ||
2 files changed, 22 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/src/Persisters/Entity/BasicEntityPersister.php b/src/Persisters/Entity/BasicEntityPersister.php | ||
index 5ca00cb00..86b01e67a 100644 | ||
--- a/src/Persisters/Entity/BasicEntityPersister.php | ||
+++ b/src/Persisters/Entity/BasicEntityPersister.php | ||
@@ -853,7 +853,17 @@ class BasicEntityPersister implements EntityPersister | ||
$dataValue = $sourceEntityData[$sourceKeyColumn]; | ||
if ($dataValue !== null) { | ||
$resolvedSourceData = true; | ||
- $computedIdentifier[$targetClass->getFieldForColumn($targetKeyColumn)] = | ||
+ // The following was introduced in v2.19 to fix an issue related to | ||
+ // resolving inverse one-to-one relations. This should not impact our | ||
+ // specific issue, however, we believe we should replace all instances | ||
+ // of the affected code. | ||
+ // See https://github.com/doctrine/orm/issues/7579 for more information. | ||
+ // | ||
+ // Original: | ||
+ // $computedIdentifier[$targetClass->getFieldForColumn($targetKeyColumn)] = | ||
+ // | ||
+ // Patched: | ||
+ $computedIdentifier[$this->getSQLTableAlias($targetClass->name) . '.' . $targetKeyColumn] = | ||
$dataValue; | ||
} | ||
} | ||
@@ -865,7 +875,15 @@ class BasicEntityPersister implements EntityPersister | ||
); | ||
} | ||
} else { | ||
- $computedIdentifier[$targetClass->getFieldForColumn($targetKeyColumn)] = | ||
+ // Revert change made in v2.6, which causes one-to-one relations with an | ||
+ // @JoinColumns annotation to break. Is required for Decisions. | ||
+ // See https://github.com/doctrine/orm/issues/7579 for more information. | ||
+ // | ||
+ // Original: | ||
+ // $computedIdentifier[$targetClass->getFieldForColumn($targetKeyColumn)] = | ||
+ // | ||
+ // Patched: | ||
+ $computedIdentifier[$this->getSQLTableAlias($targetClass->name) . '.' . $targetKeyColumn] = | ||
$sourceClass->reflFields[$sourceClass->fieldNames[$sourceKeyColumn]]->getValue($sourceEntity); | ||
} | ||
} | ||
diff --git a/tests/Tests/ORM/Functional/Ticket/GH5887Test.php b/tests/Tests/ORM/Functional/Ticket/GH5887Test.php | ||
index 1cc6169df..be836fbaa 100644 | ||
--- a/tests/Tests/ORM/Functional/Ticket/GH5887Test.php | ||
+++ b/tests/Tests/ORM/Functional/Ticket/GH5887Test.php | ||
@@ -31,6 +31,8 @@ class GH5887Test extends OrmFunctionalTestCase | ||
|
||
public function testLazyLoadsForeignEntitiesInOneToOneRelationWhileHavingCustomIdObject(): void | ||
{ | ||
+ $this->markTestSkipped('This test is marked as skipped due to a custom patch made to Doctrine\ORM\Persisters\Entity\BasicEntityPersister. It fails to lazy-load an object with a custom id. Since there are no custom ids present, failure of this test case can be ignored.'); | ||
+ | ||
$customerId = new GH5887CustomIdObject(1); | ||
$customer = new GH5887Customer(); | ||
$customer->setId($customerId); | ||
-- | ||
2.46.2 | ||
|