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

Prevented "Undefined index" notice when updating #484

Merged
merged 2 commits into from Oct 22, 2012
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/UnitOfWork.php
Expand Up @@ -982,7 +982,7 @@ private function executeUpdates($class)
); );
} }


if ($this->entityChangeSets[$oid]) { if (!empty($this->entityChangeSets[$oid])) {
$persister->update($entity); $persister->update($entity);
} }


Expand Down
25 changes: 24 additions & 1 deletion tests/Doctrine/Tests/ORM/UnitOfWorkTest.php
Expand Up @@ -204,6 +204,29 @@ public function testGetEntityStateWithAssignedIdentity()
$this->assertEquals(UnitOfWork::STATE_DETACHED, $this->_unitOfWork->getEntityState($ph2)); $this->assertEquals(UnitOfWork::STATE_DETACHED, $this->_unitOfWork->getEntityState($ph2));
$this->assertFalse($persister->isExistsCalled()); $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();
}
} }


/** /**
Expand Down Expand Up @@ -309,4 +332,4 @@ class VersionedAssignedIdentifierEntity
* @Version @Column(type="integer") * @Version @Column(type="integer")
*/ */
public $version; public $version;
} }