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

Fix #7629 - scheduledForSynchronization leaks memory when using @ORM\ChangeTrackingPolicy("DEFERRED_EXPLICIT") #7630

Merged
merged 2 commits into from
Mar 1, 2019
Merged
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
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;
}