DDC-2931 - Detailed explanation
This commit is contained in:
parent
22bcfef523
commit
9eafb11a02
@ -38,8 +38,18 @@ class DDC2931Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
|||||||
$this->_em->flush();
|
$this->_em->flush();
|
||||||
$this->_em->clear();
|
$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
|
// Load Entity in second order
|
||||||
$second = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC2931User', $second->id);
|
$second = $this->_em->find('Doctrine\Tests\ORM\Functional\Ticket\DDC2931User', $second->id);
|
||||||
|
|
||||||
$this->assertSame(2, $second->getRank());
|
$this->assertSame(2, $second->getRank());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -65,6 +75,13 @@ class DDC2931User
|
|||||||
*/
|
*/
|
||||||
public function getRank()
|
public function getRank()
|
||||||
{
|
{
|
||||||
|
//$id = $this->parent->id;
|
||||||
|
//$hash = spl_object_hash($this);
|
||||||
return 1 + ($this->parent ? $this->parent->getRank() : 0);
|
return 1 + ($this->parent ? $this->parent->getRank() : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __wakeup()
|
||||||
|
{
|
||||||
|
echo 'foo';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user