From 55b7e4cff22e624c9bf9de31d67b120964b0c919 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sun, 23 Mar 2014 12:35:54 +0100 Subject: [PATCH] [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. --- lib/Doctrine/ORM/UnitOfWork.php | 8 ++++---- .../Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 8120352c7..e10acd9da 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -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); } } diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php index cdc6c7b6c..4cb78d399 100644 --- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3033Test.php @@ -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; }