DDC-920 - Fix bug when detaching a managed entity that is not yet in the identity map (no id).
This commit is contained in:
parent
06326918a5
commit
4f154b6aa1
@ -1509,7 +1509,9 @@ class UnitOfWork implements PropertyChangedListener
|
||||
|
||||
switch ($this->getEntityState($entity, self::STATE_DETACHED)) {
|
||||
case self::STATE_MANAGED:
|
||||
$this->removeFromIdentityMap($entity);
|
||||
if ($this->isInIdentityMap($entity)) {
|
||||
$this->removeFromIdentityMap($entity);
|
||||
}
|
||||
unset($this->entityInsertions[$oid], $this->entityUpdates[$oid],
|
||||
$this->entityDeletions[$oid], $this->entityIdentifiers[$oid],
|
||||
$this->entityStates[$oid], $this->originalEntityData[$oid]);
|
||||
|
@ -173,5 +173,23 @@ class DetachedEntityTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$this->assertType('Doctrine\Tests\Models\CMS\CmsUser', $newUser);
|
||||
$this->assertEquals('gblanco', $newUser->username);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-920
|
||||
*/
|
||||
public function testDetachManagedUnpersistedEntity()
|
||||
{
|
||||
$user = new CmsUser;
|
||||
$user->name = 'Guilherme';
|
||||
$user->username = 'gblanco';
|
||||
$user->status = 'developer';
|
||||
|
||||
$this->_em->persist($user);
|
||||
$this->_em->detach($user);
|
||||
|
||||
$this->_em->flush();
|
||||
|
||||
$this->assertNull($user->id);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user