From ba496fd3ad1c4ea2b74ac52ca68cbf71512ec87d Mon Sep 17 00:00:00 2001 From: romanb <romanb@625475ce-881a-0410-a577-b389adb331d8> Date: Thu, 19 Nov 2009 13:26:27 +0000 Subject: [PATCH] [2.0][DDC-158] Small correction to previous patch. Moved takeSnapshot up in order not lose new objects that were added before initialization. --- lib/Doctrine/ORM/PersistentCollection.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/PersistentCollection.php b/lib/Doctrine/ORM/PersistentCollection.php index b7e7d7ccb..4cff149bd 100644 --- a/lib/Doctrine/ORM/PersistentCollection.php +++ b/lib/Doctrine/ORM/PersistentCollection.php @@ -235,13 +235,13 @@ final class PersistentCollection implements \Doctrine\Common\Collections\Collect } $this->_coll->clear(); $this->_association->load($this->_owner, $this, $this->_em); + $this->takeSnapshot(); // Reattach NEW objects added through add(), if any. if (isset($newObjects)) { foreach ($newObjects as $obj) { $this->_coll->add($obj); } } - $this->takeSnapshot(); $this->_initialized = true; } } @@ -435,6 +435,8 @@ final class PersistentCollection implements \Doctrine\Common\Collections\Collect // SQL "SELECT 1" on the association (table) without initializing // the collection. + // TODO: Change to use PK identity, not php object identity!? + $this->_initialize(); return $this->_coll->contains($element); }