Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DDC-3619] Update identityMap when entity gets managed again #1338

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/Doctrine/ORM/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -1682,6 +1682,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;
Expand Down
46 changes: 46 additions & 0 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3619Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

namespace Doctrine\Tests\ORM\Functional\Ticket;

class DDC3619Test extends \Doctrine\Tests\OrmFunctionalTestCase
{
protected function setup()
{
parent::setup();

$this->_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;
}