Skip to content

Commit

Permalink
Add patch
Browse files Browse the repository at this point in the history
  • Loading branch information
tomudding committed Jan 1, 2024
1 parent 06c8d9a commit 7557a20
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions 1-to-1-multiple-join-columns.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
From 06c8d9ac6c12794b6464d8c1a768a94b5d80c4c8 Mon Sep 17 00:00:00 2001
From: Tom Udding <[email protected]>
Date: Mon, 1 Jan 2024 14:23:00 +0100
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.
---
.../ORM/Persisters/Entity/BasicEntityPersister.php | 10 +++++++++-
.../Tests/ORM/Functional/Ticket/GH5887Test.php | 2 ++
2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php
index 0d11dc923..c54e9fc87 100644
--- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php
+++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php
@@ -836,7 +836,15 @@ class BasicEntityPersister implements EntityPersister
);
}

- $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/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php
index 1cc6169df..be836fbaa 100644
--- a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH5887Test.php
+++ b/tests/Doctrine/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.42.0

0 comments on commit 7557a20

Please sign in to comment.