diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index c79afd084ee..0fb3d8a06e1 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -356,6 +356,8 @@ public function commit($entity = null) $this->dispatchOnFlushEvent(); $this->dispatchPostFlushEvent(); + $this->postCommitCleanup($entity); + return; // Nothing to do. } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7629Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7629Test.php new file mode 100644 index 00000000000..a0c100acaaa --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/GH7629Test.php @@ -0,0 +1,48 @@ +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; +}