Merge branch 'DDC-1041'
This commit is contained in:
commit
1d5fef4144
@ -355,7 +355,7 @@ class EntityManager implements ObjectManager
|
|||||||
|
|
||||||
// Check identity map first, if its already in there just return it.
|
// Check identity map first, if its already in there just return it.
|
||||||
if ($entity = $this->unitOfWork->tryGetById($identifier, $class->rootEntityName)) {
|
if ($entity = $this->unitOfWork->tryGetById($identifier, $class->rootEntityName)) {
|
||||||
return $entity;
|
return ($entity instanceof $class->name) ? $entity : null;
|
||||||
}
|
}
|
||||||
if ($class->subClasses) {
|
if ($class->subClasses) {
|
||||||
$entity = $this->find($entityName, $identifier);
|
$entity = $this->find($entityName, $identifier);
|
||||||
@ -395,7 +395,7 @@ class EntityManager implements ObjectManager
|
|||||||
|
|
||||||
// Check identity map first, if its already in there just return it.
|
// Check identity map first, if its already in there just return it.
|
||||||
if ($entity = $this->unitOfWork->tryGetById($identifier, $class->rootEntityName)) {
|
if ($entity = $this->unitOfWork->tryGetById($identifier, $class->rootEntityName)) {
|
||||||
return $entity;
|
return ($entity instanceof $class->name) ? $entity : null;
|
||||||
}
|
}
|
||||||
if ( ! is_array($identifier)) {
|
if ( ! is_array($identifier)) {
|
||||||
$identifier = array($class->identifier[0] => $identifier);
|
$identifier = array($class->identifier[0] => $identifier);
|
||||||
|
@ -98,6 +98,10 @@ class EntityRepository implements ObjectRepository
|
|||||||
{
|
{
|
||||||
// Check identity map first
|
// Check identity map first
|
||||||
if ($entity = $this->_em->getUnitOfWork()->tryGetById($id, $this->_class->rootEntityName)) {
|
if ($entity = $this->_em->getUnitOfWork()->tryGetById($id, $this->_class->rootEntityName)) {
|
||||||
|
if (!($entity instanceof $this->_class->name)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if ($lockMode != LockMode::NONE) {
|
if ($lockMode != LockMode::NONE) {
|
||||||
$this->_em->lock($entity, $lockMode, $lockVersion);
|
$this->_em->lock($entity, $lockMode, $lockVersion);
|
||||||
}
|
}
|
||||||
|
33
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php
Normal file
33
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1041Test.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||||
|
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
require_once __DIR__ . '/../../../TestInit.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group DDC-1041
|
||||||
|
*/
|
||||||
|
class DDC1041Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||||
|
{
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
$this->useModelSet('company');
|
||||||
|
parent::setUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGrabWrongSubtypeReturnsNull()
|
||||||
|
{
|
||||||
|
$fix = new \Doctrine\Tests\Models\Company\CompanyFixContract();
|
||||||
|
$fix->setFixPrice(2000);
|
||||||
|
|
||||||
|
$this->_em->persist($fix);
|
||||||
|
$this->_em->flush();
|
||||||
|
|
||||||
|
$id = $fix->getId();
|
||||||
|
|
||||||
|
$this->assertNull($this->_em->find('Doctrine\Tests\Models\Company\CompanyFlexContract', $id));
|
||||||
|
$this->assertNull($this->_em->getReference('Doctrine\Tests\Models\Company\CompanyFlexContract', $id));
|
||||||
|
$this->assertNull($this->_em->getPartialReference('Doctrine\Tests\Models\Company\CompanyFlexContract', $id));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user