-
-
Save doctrinebot/f48236ab9f321b1c3f4a to your computer and use it in GitHub Desktop.
Attachments to Doctrine Jira Issue DDC-444 - https://github.com/doctrine/doctrine2/issues/4945
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: lib/Doctrine/ORM/UnitOfWork.php | |
=================================================================== | |
--- lib/Doctrine/ORM/UnitOfWork.php (revision 7428) | |
+++ lib/Doctrine/ORM/UnitOfWork.php (working copy) | |
@@ -521,7 +521,8 @@ | |
// If change tracking is explicit, then only compute changes on explicitly saved entities | |
$entitiesToProcess = $class->isChangeTrackingDeferredExplicit() ? | |
- $this->_scheduledForDirtyCheck[$className] : $entities; | |
+ (isset($this->_scheduledForDirtyCheck[$className]) ? $this->_scheduledForDirtyCheck[$className] : array()) | |
+ : $entities; | |
foreach ($entitiesToProcess as $entity) { | |
// Ignore uninitialized proxy objects | |
@@ -1927,7 +1928,7 @@ | |
public function scheduleForDirtyCheck($entity) | |
{ | |
$rootClassName = $this->_em->getClassMetadata(get_class($entity))->rootEntityName; | |
- $this->_scheduledForDirtyCheck[$rootClassName] = $entity; | |
+ $this->_scheduledForDirtyCheck[$rootClassName][] = $entity; | |
} | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php | |
=================================================================== | |
--- tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php (revision 0) | |
+++ tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php (revision 0) | |
@@ -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; | |
+} | |
+ | |
+ | |
Property changes on: tests/Doctrine/Tests/ORM/Functional/Ticket/DDC444Test.php | |
___________________________________________________________________ | |
Added: svn:keywords | |
+ Id Rev Revision | |
Added: svn:eol-style | |
+ native | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment