1
0
mirror of synced 2025-02-09 00:39:25 +03:00

[DDC-3033] Fix bug in UnitOfWork#recomputeSingleEntityChangeSet.

The fix for DDC-2624 had a side effect on recomputation of
changesets in preUpdate events. The method wasn't adjusted
to the changes in its sister method computeChangeSet() and
had wrong assumptions about the computation.

Especially:
1. Collections have to be skipped
2. Comparison was changed to strict equality only.
This commit is contained in:
Benjamin Eberlei 2014-03-23 12:35:54 +01:00
parent e38af55100
commit 55b7e4cff2
2 changed files with 7 additions and 7 deletions

View File

@ -902,7 +902,9 @@ class UnitOfWork implements PropertyChangedListener
$actualData = array();
foreach ($class->reflFields as $name => $refProp) {
if ( ! $class->isIdentifier($name) || ! $class->isIdGeneratorIdentity()) {
if (( ! $class->isIdentifier($name) || ! $class->isIdGeneratorIdentity())
&& ($name !== $class->versionField)
&& ! $class->isCollectionValuedAssociation($name)) {
$actualData[$name] = $refProp->getValue($entity);
}
}
@ -913,9 +915,7 @@ class UnitOfWork implements PropertyChangedListener
foreach ($actualData as $propName => $actualValue) {
$orgValue = isset($originalData[$propName]) ? $originalData[$propName] : null;
if (is_object($orgValue) && $orgValue !== $actualValue) {
$changeSet[$propName] = array($orgValue, $actualValue);
} else if ($orgValue != $actualValue || ($orgValue === null ^ $actualValue === null)) {
if ($orgValue !== $actualValue) {
$changeSet[$propName] = array($orgValue, $actualValue);
}
}

View File

@ -20,11 +20,11 @@ class DDC3033Test extends \Doctrine\Tests\OrmFunctionalTestCase
));
$user = new DDC3033User();
$user->title = "Test User";
$user->name = "Test User";
$this->_em->persist($user);
$user2 = new DDC3033User();
$user2->title = "Test User 2";
$user2->name = "Test User 2";
$this->_em->persist($user2);
$product = new DDC3033Product();
@ -135,5 +135,5 @@ class DDC3033User
*
* @Column(name="title", type="string", length=255)
*/
public $title;
public $name;
}