[+BUGFIX] Extbase (Persistence): Fixed a problem where an empty parent property field...
authorJochen Rau <j.rau@web.de>
Wed, 25 Nov 2009 10:33:08 +0000 (10:33 +0000)
committerJochen Rau <j.rau@web.de>
Wed, 25 Nov 2009 10:33:08 +0000 (10:33 +0000)
[+BUGFIX] Extbase (Persistence): Fixed a problem introduced with the last commit where the property type was not detected as an ObjectStorage.

typo3/sysext/extbase/Classes/Persistence/Backend.php
typo3/sysext/extbase/Classes/Persistence/Mapper/DataMapper.php

index 8bd923e..c82526b 100644 (file)
@@ -353,17 +353,10 @@ class Tx_Extbase_Persistence_Backend implements Tx_Extbase_Persistence_BackendIn
                        $columnMap = $dataMap->getColumnMap($propertyName);
                        $childClassName = $columnMap->getChildClassName();
                        $propertyMetaData = $classSchema->getProperty($propertyName);
-                       if (!empty($childClassName)) {
-                               $propertyType = $childClassName;
-                       } elseif (!empty($propertyMetaData['type'])) {
-                               $propertyType = $propertyMetaData['type'];
-                       } else {
-                               throw new Tx_Extbase_Persistence_Exception_UnexpectedTypeException('Could not determine the class of the child objects.', 1251315965);
-                       }
-                       
+                       $propertyType = $propertyMetaData['type'];
                        // FIXME enable property-type check
                        // $this->checkPropertyType($propertyType, $propertyValue);
-                       if (($propertyValue !== NULL) && $propertyType === 'Tx_Extbase_Persistence_ObjectStorage') {
+                       if (($propertyValue !== NULL) && ($propertyValue instanceof Tx_Extbase_Persistence_ObjectStorage || $propertyType === 'Tx_Extbase_Persistence_ObjectStorage')) {
                                if ($object->_isNew() || $object->_isDirty($propertyName)) {
                                        $this->persistObjectStorage($propertyValue, $object, $propertyName, $queue, $row);
                                }
index 3f83585..f0b2d86 100644 (file)
@@ -243,6 +243,7 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
         * @return void
         */
        protected function fetchRelatedEager(Tx_Extbase_DomainObject_AbstractEntity $parentObject, $propertyName, $fieldValue = '') {
+               if ($fieldValue === '') return array();
                $query = $this->getPreparedQuery($parentObject, $propertyName, $fieldValue);
                return $query->execute();
        }
@@ -262,7 +263,7 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
                $childSortByFieldName = $columnMap->getChildSortByFieldName();
                if ($columnMap->getTypeOfRelation() === Tx_Extbase_Persistence_Mapper_ColumnMap::RELATION_HAS_ONE) {
                        $query = $queryFactory->create($this->getType($parentObject, $propertyName));
-                       $result = $query->matching($query->withUid(intval($fieldValue)));
+                       $query->matching($query->withUid(intval($fieldValue)));
                } elseif ($columnMap->getTypeOfRelation() === Tx_Extbase_Persistence_Mapper_ColumnMap::RELATION_HAS_MANY) {
                        $query = $queryFactory->create($this->getElementType($parentObject, $propertyName));
                        // TODO: This is an ugly hack, just ignoring the storage page state from here. Actually, the query settings would have to be passed into the DataMapper, so we can respect
@@ -272,9 +273,9 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
                                $query->setOrderings(array($childSortByFieldName => Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING));
                        }
                        if (isset($parentKeyFieldName)) {
-                               $result = $query->matching($query->equals($parentKeyFieldName, $parentObject->getUid()));
+                               $query->matching($query->equals($parentKeyFieldName, $parentObject->getUid()));
                        } else {
-                               $result = $query->matching($query->equals('uid', t3lib_div::intExplode(',', $fieldValue)));                                     
+                               $query->matching($query->equals('uid', t3lib_div::intExplode(',', $fieldValue)));                                       
                        }
                } elseif ($columnMap->getTypeOfRelation() === Tx_Extbase_Persistence_Mapper_ColumnMap::RELATION_HAS_AND_BELONGS_TO_MANY) {
                        $query = $queryFactory->create($this->getElementType($parentObject, $propertyName));
@@ -297,7 +298,7 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
                        if (!empty($childSortByFieldName)) {
                                $query->setOrderings(array($relationTableName . '.' . $childSortByFieldName => Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING));
                        }
-                       $result = $query->matching($query->equals($parentKeyFieldName, $parentObject->getUid()));
+                       $query->matching($query->equals($parentKeyFieldName, $parentObject->getUid()));
                } else {
                        throw new Tx_Extbase_Persistence_Exception('Could not determine type of relation.', 1252502725);
                }