8000 Merge branch 'hotfix/#1338-identity-map-garbage-collection-prevention… · symfonyaml/orm@1c8f9ca · GitHub
[go: up one dir, main page]

Skip to content

Commit 1c8f9ca

Browse files
committed
Merge branch 'hotfix/doctrine#1338-identity-map-garbage-collection-prevention-on-canceled-remove-2.4' into 2.4
2 parents 18c8732 + 7aa33c6 commit 1c8f9ca

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/Doctrine/ORM/UnitOfWork.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,6 +1630,7 @@ private function doPersist($entity, array &$visited)
16301630
case self::STATE_REMOVED:
16311631
// Entity becomes managed again
16321632
unset($this->entityDeletions[$oid]);
1633+
$this->addToIdentityMap($entity);
16331634

16341635
$this->entityStates[$oid] = self::STATE_MANAGED;
16351636
break;

tests/Doctrine/Tests/ORM/UnitOfWorkTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,25 @@ public function testLockWithoutEntityThrowsException()
229229
$this->setExpectedException('InvalidArgumentException');
230230
$this->_unitOfWork->lock(null, null, null);
231231
}
232+
233+
/**
234+
* @group DDC-3619
235+
* @group 1338
236+
*/
237+
public function testRemovedAndRePersistedEntitiesAreInTheIdentityMapAndAreNotGarbageCollected()
238+
{
239+
$entity = new ForumUser();
240+
$entity->id = 123;
241+
242+
$this->_unitOfWork->registerManaged($entity, array('id' => 123), array());
243+
$this->assertTrue($this->_unitOfWork->isInIdentityMap($entity));
244+
245+
$this->_unitOfWork->remove($entity);
246+
$this->assertFalse($this->_unitOfWork->isInIdentityMap($entity));
247+
248+
$this->_unitOfWork->persist($entity);
249+
$this->assertTrue($this->_unitOfWork->isInIdentityMap($entity));
250+
}
232251
}
233252

234253
/**

0 commit comments

Comments
 (0)
0