DDC-1043 - Make computeChangeSet() algorithm more strict, possible leading to more updates to to values that are not exactly the same. However this is necessary to avoid bugs with certain PHP casting rules, i.e. +44 = 44
This commit is contained in:
parent
5a6ac2fb56
commit
7a068c206e
@ -474,9 +474,7 @@ class UnitOfWork implements PropertyChangedListener
|
||||
}
|
||||
} else if ($isChangeTrackingNotify) {
|
||||
continue;
|
||||
} else if (is_object($orgValue) && $orgValue !== $actualValue) {
|
||||
$changeSet[$propName] = array($orgValue, $actualValue);
|
||||
} else if ($orgValue != $actualValue || ($orgValue === null ^ $actualValue === null)) {
|
||||
} else if ($orgValue !== $actualValue) {
|
||||
$changeSet[$propName] = array($orgValue, $actualValue);
|
||||
}
|
||||
}
|
||||
|
36
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php
Normal file
36
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1043Test.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
require_once __DIR__ . '/../../../TestInit.php';
|
||||
|
||||
/**
|
||||
* @group DDC-1043
|
||||
*/
|
||||
class DDC1043Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
$this->useModelSet('cms');
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function testChangeSetPlusWeirdPHPCastingIntCastingRule()
|
||||
{
|
||||
$user = new \Doctrine\Tests\Models\CMS\CmsUser();
|
||||
$user->name = "John Galt";
|
||||
$user->username = "jgalt";
|
||||
$user->status = "+44";
|
||||
|
||||
$this->_em->persist($user);
|
||||
$this->_em->flush();
|
||||
|
||||
$user->status = "44";
|
||||
$this->_em->flush();
|
||||
$this->_em->clear();
|
||||
|
||||
$user = $this->_em->find("Doctrine\Tests\Models\CMS\CmsUser", $user->id);
|
||||
$this->assertSame("44", $user->status);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user