From 0cfc37d757d6ca2eaae4f2be027522d778a642a2 Mon Sep 17 00:00:00 2001 From: "Jasper N. Brouwer" Date: Wed, 17 Oct 2012 21:50:09 +0200 Subject: [PATCH 1/2] Prevented "Undefined index" notice when updating While executing updates on an entity scheduled for update without a change-set, an "Undefined index" notice is raised. --- lib/Doctrine/ORM/UnitOfWork.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index bd075b95b..c5f7837e8 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -982,7 +982,7 @@ class UnitOfWork implements PropertyChangedListener ); } - if ($this->entityChangeSets[$oid]) { + if (!empty($this->entityChangeSets[$oid])) { $persister->update($entity); } From 1a17b1670b0c5c98027f0350fd69254a72287436 Mon Sep 17 00:00:00 2001 From: "Jasper N. Brouwer" Date: Fri, 19 Oct 2012 09:15:07 +0200 Subject: [PATCH 2/2] Added testcase for DDC-2086 --- tests/Doctrine/Tests/ORM/UnitOfWorkTest.php | 25 ++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php index 9cc20ad73..e091483e3 100644 --- a/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php +++ b/tests/Doctrine/Tests/ORM/UnitOfWorkTest.php @@ -204,6 +204,29 @@ class UnitOfWorkTest extends \Doctrine\Tests\OrmTestCase $this->assertEquals(UnitOfWork::STATE_DETACHED, $this->_unitOfWork->getEntityState($ph2)); $this->assertFalse($persister->isExistsCalled()); } + + /** + * DDC-2086 [GH-484] Prevented "Undefined index" notice when updating. + */ + public function testNoUndefinedIndexNoticeOnScheduleForUpdateWithoutChanges() + { + // Setup fake persister and id generator + $userPersister = new EntityPersisterMock($this->_emMock, $this->_emMock->getClassMetadata("Doctrine\Tests\Models\Forum\ForumUser")); + $userPersister->setMockIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_IDENTITY); + $this->_unitOfWork->setEntityPersister('Doctrine\Tests\Models\Forum\ForumUser', $userPersister); + + // Create a test user + $user = new ForumUser(); + $user->name = 'Jasper'; + $this->_unitOfWork->persist($user); + $this->_unitOfWork->commit(); + + // Schedule user for update without changes + $this->_unitOfWork->scheduleForUpdate($user); + + // This commit should not raise an E_NOTICE + $this->_unitOfWork->commit(); + } } /** @@ -309,4 +332,4 @@ class VersionedAssignedIdentifierEntity * @Version @Column(type="integer") */ public $version; -} \ No newline at end of file +}