[+BUGFIX] Extbase (Persistence): Fixed handling of cloned object storages.
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / ObjectStorage.php
index be8fea4..16115bf 100644 (file)
@@ -272,6 +272,17 @@ class Tx_Extbase_Persistence_ObjectStorage implements Iterator, Countable, Array
                return $this->storage;
        }
 
+       public function __clone() {
+               if ($this->isInitialized()) {
+                       $clonedStorage = array();
+                       foreach ($this->storage as $object) {
+                               if ($object instanceof Tx_Extbase_DomainObject_AbstractDomainObject) {
+                                       $clonedStorage[] = clone $object;
+                               }
+                       }
+                       $this->storage = $clonedStorage;
+               }
+       }
 }
 
 ?>
\ No newline at end of file