-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update identityMap when entity gets managed again
http://www.doctrine-project.org/jira/browse/DDC-3619 When using SoftDeleteable doctrine extension, an entity can be scheduled for deletion, then persisted before flushing. In such a case, the entity was removed from the unit of work identity map and no reference was hold. This could lead to spl_object_hash collisions, and prevent another, new entity to be persisted later. This fix makes sure the unit of work identity map holds a reference to the entity after it has been soft-deleted.
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3619Test.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |