diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 80915155d9d..2a458a3ceda 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -1684,6 +1684,7 @@ private function doPersist($entity, array &$visited) case self::STATE_REMOVED: // Entity becomes managed again unset($this->entityDeletions[$oid]); + $this->addToIdentityMap($entity); $this->entityStates[$oid] = self::STATE_MANAGED; break; diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3619Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3619Test.php new file mode 100644 index 00000000000..2d22c907cb8 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3619Test.php @@ -0,0 +1,46 @@ +_schemaTool->createSchema( + array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC3619Entity'), + ) + ); + } + + public function testIssue() + { + $uow = $this->_em->getUnitOfWork(); + + $entity = new DDC3619Entity(); + $this->_em->persist($entity); + $this->_em->flush(); + $this->assertTrue($uow->isInIdentityMap($entity)); + + $this->_em->remove($entity); + $this->assertFalse($uow->isInIdentityMap($entity)); + + $this->_em->persist($entity); + $this->assertTrue($uow->isInIdentityMap($entity)); + } +} + +/** + * @Entity() + */ +class DDC3619Entity +{ + /** + * @Id + * @Column(type="integer") + * @GeneratedValue(strategy="IDENTITY") + */ + protected $id; +}