[2.0][DDC-444] Fixed.
This commit is contained in:
parent
f34a99ccce
commit
2209c5ef30
@ -519,9 +519,11 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If change tracking is explicit, then only compute changes on explicitly saved entities
|
// If change tracking is explicit, then only compute changes on explicitly persisted entities
|
||||||
$entitiesToProcess = $class->isChangeTrackingDeferredExplicit() ?
|
$entitiesToProcess = $class->isChangeTrackingDeferredExplicit() ?
|
||||||
$this->_scheduledForDirtyCheck[$className] : $entities;
|
(isset($this->_scheduledForDirtyCheck[$className]) ?
|
||||||
|
$this->_scheduledForDirtyCheck[$className] : array())
|
||||||
|
: $entities;
|
||||||
|
|
||||||
foreach ($entitiesToProcess as $entity) {
|
foreach ($entitiesToProcess as $entity) {
|
||||||
// Ignore uninitialized proxy objects
|
// Ignore uninitialized proxy objects
|
||||||
@ -1927,7 +1929,7 @@ class UnitOfWork implements PropertyChangedListener
|
|||||||
public function scheduleForDirtyCheck($entity)
|
public function scheduleForDirtyCheck($entity)
|
||||||
{
|
{
|
||||||
$rootClassName = $this->_em->getClassMetadata(get_class($entity))->rootEntityName;
|
$rootClassName = $this->_em->getClassMetadata(get_class($entity))->rootEntityName;
|
||||||
$this->_scheduledForDirtyCheck[$rootClassName] = $entity;
|
$this->_scheduledForDirtyCheck[$rootClassName][] = $entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
76
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php
Normal file
76
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Doctrine\Tests\ORM\Functional\Ticket;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../../../TestInit.php';
|
||||||
|
|
||||||
|
class DDC444Test extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||||
|
{
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
$this->_schemaTool->createSchema(array(
|
||||||
|
$this->_em->getClassMetadata(__NAMESPACE__ . '\DDC444User'),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testExplicitPolicy()
|
||||||
|
{
|
||||||
|
$classname = __NAMESPACE__ . "\DDC444User";
|
||||||
|
|
||||||
|
$u = new $classname;
|
||||||
|
$u->name = "Initial value";
|
||||||
|
|
||||||
|
$this->_em->persist($u);
|
||||||
|
$this->_em->flush();
|
||||||
|
$this->_em->clear();
|
||||||
|
|
||||||
|
$q = $this->_em->createQuery("SELECT u FROM $classname u");
|
||||||
|
$u = $q->getSingleResult();
|
||||||
|
$this->assertEquals("Initial value", $u->name);
|
||||||
|
|
||||||
|
$u->name = "Modified value";
|
||||||
|
|
||||||
|
// This should be NOOP as the change hasn't been persisted
|
||||||
|
$this->_em->flush();
|
||||||
|
$this->_em->clear();
|
||||||
|
|
||||||
|
|
||||||
|
$u = $this->_em->createQuery("SELECT u FROM $classname u");
|
||||||
|
$u = $q->getSingleResult();
|
||||||
|
|
||||||
|
$this->assertEquals("Initial value", $u->name);
|
||||||
|
|
||||||
|
|
||||||
|
$u->name = "Modified value";
|
||||||
|
$this->_em->persist($u);
|
||||||
|
// Now we however persisted it, and this should have updated our friend
|
||||||
|
$this->_em->flush();
|
||||||
|
|
||||||
|
$q = $this->_em->createQuery("SELECT u FROM $classname u");
|
||||||
|
$u = $q->getSingleResult();
|
||||||
|
|
||||||
|
$this->assertEquals("Modified value", $u->name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Entity @Table(name="ddc444")
|
||||||
|
* @ChangeTrackingPolicy("DEFERRED_EXPLICIT")
|
||||||
|
*/
|
||||||
|
class DDC444User
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @Id @Column(name="id", type="integer")
|
||||||
|
* @GeneratedValue(strategy="AUTO")
|
||||||
|
*/
|
||||||
|
public $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Column(name="name", type="string")
|
||||||
|
*/
|
||||||
|
public $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user