[BUGFIX] Repository replace() does not replace unpersisted objects
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / Repository.php
index dfd0c76..30523bc 100644 (file)
@@ -197,6 +197,9 @@ class Tx_Extbase_Persistence_Repository implements Tx_Extbase_Persistence_Reposi
                        if ($this->removedObjects->contains($existingObject)) {
                                $this->removedObjects->detach($existingObject);
                                $this->removedObjects->attach($newObject);
+                       } elseif ($this->addedObjects->contains($existingObject)) {
+                               $this->addedObjects->detach($existingObject);
+                               $this->addedObjects->attach($newObject);
                        }
                } elseif ($this->addedObjects->contains($existingObject)) {
                        $this->addedObjects->detach($existingObject);