1
0
mirror of synced 2025-01-31 12:32:59 +03:00

[2.0][DDC-158] Small correction to previous patch. Moved takeSnapshot up in order not lose new objects that were added before initialization.

This commit is contained in:
romanb 2009-11-19 13:26:27 +00:00
parent 61f09e335e
commit ba496fd3ad

View File

@ -235,13 +235,13 @@ final class PersistentCollection implements \Doctrine\Common\Collections\Collect
} }
$this->_coll->clear(); $this->_coll->clear();
$this->_association->load($this->_owner, $this, $this->_em); $this->_association->load($this->_owner, $this, $this->_em);
$this->takeSnapshot();
// Reattach NEW objects added through add(), if any. // Reattach NEW objects added through add(), if any.
if (isset($newObjects)) { if (isset($newObjects)) {
foreach ($newObjects as $obj) { foreach ($newObjects as $obj) {
$this->_coll->add($obj); $this->_coll->add($obj);
} }
} }
$this->takeSnapshot();
$this->_initialized = true; $this->_initialized = true;
} }
} }
@ -435,6 +435,8 @@ final class PersistentCollection implements \Doctrine\Common\Collections\Collect
// SQL "SELECT 1" on the association (table) without initializing // SQL "SELECT 1" on the association (table) without initializing
// the collection. // the collection.
// TODO: Change to use PK identity, not php object identity!?
$this->_initialize(); $this->_initialize();
return $this->_coll->contains($element); return $this->_coll->contains($element);
} }