Permalink
Browse files

Merge pull request #484 from jappie/master

Prevented "Undefined index" notice when updating
  • Loading branch information...
2 parents 814f2f9 + 1a17b16 commit cd7ef6e7a70d4ff4c25a85fdae71676aa6548ea6 @guilhermeblanco guilhermeblanco committed Oct 22, 2012
Showing with 25 additions and 2 deletions.
  1. +1 −1 lib/Doctrine/ORM/UnitOfWork.php
  2. +24 −1 tests/Doctrine/Tests/ORM/UnitOfWorkTest.php
@@ -982,7 +982,7 @@ private function executeUpdates($class)
);
}
- if ($this->entityChangeSets[$oid]) {
+ if (!empty($this->entityChangeSets[$oid])) {
$persister->update($entity);
}
@@ -204,6 +204,29 @@ public function testGetEntityStateWithAssignedIdentity()
$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;
-}
+}

0 comments on commit cd7ef6e

Please sign in to comment.