[BUGFIX] Fix persisting of lazy object storages
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / Generic / LazyObjectStorage.php
index 7aed39a..3661ddb 100644 (file)
@@ -120,10 +120,19 @@ class LazyObjectStorage extends \TYPO3\CMS\Extbase\Persistence\ObjectStorage imp
                                parent::attach($object);
                        }
                        $this->_memorizeCleanState();
-                       $this->parentObject->_memorizeCleanState($this->propertyName);
+                       if (!$this->isStorageAlreadyMemorizedInParentCleanState()) {
+                               $this->parentObject->_memorizeCleanState($this->propertyName);
+                       }
                }
        }
 
+       /**
+        * @return bool
+        */
+       protected function isStorageAlreadyMemorizedInParentCleanState() {
+               return $this->parentObject->_getCleanProperty($this->propertyName) === $this;
+       }
+
        // Delegation to the ObjectStorage methods below
        /**
         * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $storage
@@ -298,6 +307,15 @@ class LazyObjectStorage extends \TYPO3\CMS\Extbase\Persistence\ObjectStorage imp
                $this->initialize();
                return parent::toArray();
        }
+
+       /**
+        * @param mixed $object
+        * @return integer|NULL
+        */
+       public function getPosition($object) {
+               $this->initialize();
+               return parent::getPosition($object);
+       }
 }
 
 ?>
\ No newline at end of file