[+BUGFIX] Extbase (Persistence): Fixed handling of cloned object storages.
authorJochen Rau <j.rau@web.de>
Sat, 7 Nov 2009 17:00:11 +0000 (17:00 +0000)
committerJochen Rau <j.rau@web.de>
Sat, 7 Nov 2009 17:00:11 +0000 (17:00 +0000)
typo3/sysext/extbase/Classes/DomainObject/AbstractDomainObject.php
typo3/sysext/extbase/Classes/Persistence/Backend.php
typo3/sysext/extbase/Classes/Persistence/ObjectStorage.php
typo3/sysext/extbase/Classes/Utility/ClassLoader.php

index 3f04032..1669816 100644 (file)
@@ -134,7 +134,7 @@ abstract class Tx_Extbase_DomainObject_AbstractDomainObject implements Tx_Extbas
         * @return boolean
         */
        public function _isNew() {
-               return $this->uid === NULL;
+               return ($this->uid === NULL) || $this->_isClone();
        }
 
        /**
index 5929b27..d8b9de9 100644 (file)
@@ -456,8 +456,7 @@ class Tx_Extbase_Persistence_Backend implements Tx_Extbase_Persistence_BackendIn
        }
        
        /**
-        * Tests, if the given Value Object already exists in the storage backend. If so, it maps the uid
-        * to the given object.
+        * Tests, if the given Value Object already exists in the storage backend and if so, it returns the uid.
         *
         * @param Tx_Extbase_DomainObject_AbstractValueObject $object The object to be tested
         */
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
index 325fd0c..0a75cc3 100644 (file)
@@ -43,8 +43,6 @@ class Tx_Extbase_Utility_ClassLoader {
         * @return void
         */
        public static function loadClass($className) {
-               // TODO Remove debug code
-               //$starttime = microtime(true);
                $classNameParts = explode('_', $className, 3);
                $extensionKey = Tx_Extbase_Utility_Extension::convertCamelCaseToLowerCaseUnderscored($classNameParts[1]);
                if (t3lib_extMgm::isLoaded($extensionKey)) {
@@ -53,8 +51,6 @@ class Tx_Extbase_Utility_ClassLoader {
                                require($classFilePathAndName);
                        }
                }
-               //$endtime = microtime(true);
-               //debug(($endtime - $starttime) * 10000, $className);
        }
        
 }