Skip to content

Commit

Permalink
Merge pull request #7630 from yethee/gh-7629
Browse files Browse the repository at this point in the history
Fix #7629 - `scheduledForSynchronization` leaks memory when using `@ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT")`
  • Loading branch information
Ocramius authored Mar 1, 2019
2 parents de97061 + 7f5f462 commit 49a8f2e
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/Doctrine/ORM/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ public function commit($entity = null)
$this->dispatchOnFlushEvent();
$this->dispatchPostFlushEvent();

$this->postCommitCleanup($entity);

return; // Nothing to do.
}

Expand Down
48 changes: 48 additions & 0 deletions tests/Doctrine/Tests/ORM/Functional/Ticket/GH7629Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace Doctrine\Tests\ORM\Functional\Ticket;

use Doctrine\Tests\OrmFunctionalTestCase;

class GH7629Test extends OrmFunctionalTestCase
{
/**
* {@inheritDoc}
*/
protected function setUp(): void
{
parent::setUp();

$this->setUpEntitySchema([
GH7629Entity::class,
]);

$this->_em->persist(new GH7629Entity());
$this->_em->flush();
$this->_em->clear();
}

public function testClearScheduledForSynchronizationWhenCommitEmpty(): void
{
$entity = $this->_em->find(GH7629Entity::class, 1);

$this->_em->persist($entity);
$this->_em->flush();

self::assertFalse($this->_em->getUnitOfWork()->isScheduledForDirtyCheck($entity));
}
}

/**
* @Entity
* @ChangeTrackingPolicy("DEFERRED_EXPLICIT")
*/
class GH7629Entity
{
/**
* @Id
* @Column(type="integer")
* @GeneratedValue
*/
public $id;
}

0 comments on commit 49a8f2e

Please sign in to comment.