1
0
mirror of synced 2025-02-20 22:23:14 +03:00

DDC-920 - Fix bug when detaching a managed entity that is not yet in the identity map (no id).

This commit is contained in:
Benjamin Eberlei 2010-12-10 21:55:48 +01:00
parent 06326918a5
commit 4f154b6aa1
2 changed files with 21 additions and 1 deletions

View File

@ -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]);

View File

@ -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);
}
}