Skip to content

Commit

Permalink
Add patch
Browse files Browse the repository at this point in the history
  • Loading branch information
tomudding committed Oct 18, 2024
1 parent f4432f4 commit 4fd2ceb
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions 1-to-1-multiple-join-columns.patch
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

0 comments on commit 4fd2ceb

Please sign in to comment.