[+BUGFIX] Extbase (Persistence): Fixed a problem where already existing records that...
authorJochen Rau <j.rau@web.de>
Tue, 25 May 2010 11:10:49 +0000 (11:10 +0000)
committerJochen Rau <j.rau@web.de>
Tue, 25 May 2010 11:10:49 +0000 (11:10 +0000)
typo3/sysext/extbase/Classes/Persistence/Backend.php

index 82bc5af..3270334 100644 (file)
@@ -506,21 +506,11 @@ class Tx_Extbase_Persistence_Backend implements Tx_Extbase_Persistence_BackendIn
                $columnName = $columnMap->getColumnName();              
                $propertyMetaData = $this->reflectionService->getClassSchema($className)->getProperty($propertyName);
 
-               $currentUids = array();
-               if ($columnMap->getParentKeyFieldName() === NULL) {
-                       $currentFieldValue = $this->getCurrentFieldValue($parentObject, $propertyName);
-                       if (!empty($currentFieldValue)) {
-                               $currentUids = t3lib_div::intExplode(',', $currentFieldValue);
-                       }
-               }
-
-               $removedObjectUids = array();
                foreach ($this->getRemovedChildObjects($parentObject, $propertyName) as $removedObject) {
                        if ($columnMap->getTypeOfRelation() === Tx_Extbase_Persistence_Mapper_ColumnMap::RELATION_HAS_MANY && $propertyMetaData['cascade'] === 'remove') {
                                $this->removeObject($removedObject);
                        } else {
                                $this->detachObjectFromParentObject($removedObject, $parentObject, $propertyName);
-                               $removedObjectUids[] = $removedObject->getUid();
                        }
                }
 
@@ -528,7 +518,7 @@ class Tx_Extbase_Persistence_Backend implements Tx_Extbase_Persistence_BackendIn
                        $this->deleteAllRelationsFromRelationtable($parentObject, $propertyName);
                }
 
-               $insertedObjectUids = array();
+               $currentUids = array();
                $sortingPosition = 1;
                foreach ($objectStorage as $object) {
                        if ($object->_isNew()) {
@@ -537,16 +527,14 @@ class Tx_Extbase_Persistence_Backend implements Tx_Extbase_Persistence_BackendIn
                                } else {
                                        $this->persistValueObject($object, $sortingPosition);
                                }
-                               $insertedObjectUids[] = $object->getUid();
                        }
+                       $currentUids[] = $object->getUid();
                        $this->attachObjectToParentObject($object, $parentObject, $propertyName, $sortingPosition);
                        $sortingPosition++;
                }
                
                if ($columnMap->getParentKeyFieldName() === NULL) {
-                       $newUids = array_diff($currentUids, $removedObjectUids);
-                       $newUids = array_merge($newUids, $insertedObjectUids);
-                       $row[$columnMap->getColumnName()] = implode(',', $newUids);
+                       $row[$columnMap->getColumnName()] = implode(',', $currentUids);
                } else {
                        $row[$columnMap->getColumnName()] = $this->dataMapper->countRelated($parentObject, $propertyName);
                }