From 9eafb11a02afa493a9618b429966cb390a316b92 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 24 Jan 2014 02:43:14 +0100 Subject: [PATCH] DDC-2931 - Detailed explanation --- .../Tests/ORM/Functional/Ticket/DDC2931Test.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php index 9d7607491..c1b5c613b 100755 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2931Test.php @@ -38,8 +38,18 @@ class DDC2931Test extends \Doctrine\Tests\OrmFunctionalTestCase $this->_em->flush(); $this->_em->clear(); + // 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). + // 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 that in fact, the two objects don't correspond, + // and therefore marks the entity as "to be detached" + // Load Entity in second order $second = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC2931User', $second->id); + $this->assertSame(2, $second->getRank()); } } @@ -65,6 +75,13 @@ class DDC2931User */ public function getRank() { + //$id = $this->parent->id; + //$hash = spl_object_hash($this); return 1 + ($this->parent ? $this->parent->getRank() : 0); } + + public function __wakeup() + { + echo 'foo'; + } }