1
0
mirror of synced 2024-12-13 22:56:04 +03:00

Merge pull request #484 from jappie/master

Prevented "Undefined index" notice when updating
This commit is contained in:
Guilherme Blanco 2012-10-21 18:35:38 -07:00
commit cd7ef6e7a7
2 changed files with 25 additions and 2 deletions

View File

@ -982,7 +982,7 @@ class UnitOfWork implements PropertyChangedListener
);
}
if ($this->entityChangeSets[$oid]) {
if (!empty($this->entityChangeSets[$oid])) {
$persister->update($entity);
}

View File

@ -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();
}
}
/**