diff --git a/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php b/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php index d48b9dcecad120a54401802750b6b66e252b82ab..d86ea769f26d69244a9cb1d0aeac7a5d6de36141 100644 --- a/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php +++ b/typo3/sysext/extbase/Classes/Persistence/Generic/Mapper/DataMapper.php @@ -322,15 +322,13 @@ class DataMapper public function fetchRelated(DomainObjectInterface $parentObject, $propertyName, $fieldValue = '', $enableLazyLoading = true) { $property = $this->reflectionService->getClassSchema(get_class($parentObject))->getProperty($propertyName); - if ($enableLazyLoading === true && $property->isLazy()) { + if ($enableLazyLoading && $property->isLazy()) { if ($property->getType() === ObjectStorage::class) { $result = GeneralUtility::makeInstance(LazyObjectStorage::class, $parentObject, $propertyName, $fieldValue, $this); + } elseif (empty($fieldValue)) { + $result = null; } else { - if (empty($fieldValue)) { - $result = null; - } else { - $result = GeneralUtility::makeInstance(LazyLoadingProxy::class, $parentObject, $propertyName, $fieldValue, $this); - } + $result = GeneralUtility::makeInstance(LazyLoadingProxy::class, $parentObject, $propertyName, $fieldValue, $this); } } else { $result = $this->fetchRelatedEager($parentObject, $propertyName, $fieldValue); @@ -620,17 +618,15 @@ class DataMapper if ($this->propertyMapsByForeignKey($parentObject, $propertyName)) { $result = $this->fetchRelated($parentObject, $propertyName, $fieldValue); $propertyValue = $this->mapResultToPropertyValue($parentObject, $propertyName, $result); + } elseif (empty($fieldValue)) { + $propertyValue = $this->getEmptyRelationValue($parentObject, $propertyName); } else { - if ($fieldValue === '') { - $propertyValue = $this->getEmptyRelationValue($parentObject, $propertyName); + $property = $this->reflectionService->getClassSchema(get_class($parentObject))->getProperty($propertyName); + if ($this->persistenceSession->hasIdentifier($fieldValue, $property->getType())) { + $propertyValue = $this->persistenceSession->getObjectByIdentifier($fieldValue, $property->getType()); } else { - $property = $this->reflectionService->getClassSchema(get_class($parentObject))->getProperty($propertyName); - if ($this->persistenceSession->hasIdentifier($fieldValue, $property->getType())) { - $propertyValue = $this->persistenceSession->getObjectByIdentifier($fieldValue, $property->getType()); - } else { - $result = $this->fetchRelated($parentObject, $propertyName, $fieldValue); - $propertyValue = $this->mapResultToPropertyValue($parentObject, $propertyName, $result); - } + $result = $this->fetchRelated($parentObject, $propertyName, $fieldValue); + $propertyValue = $this->mapResultToPropertyValue($parentObject, $propertyName, $result); } }