Bug #34134

PropertyMapper throws unnecessary exception

Added by Kira Backes over 9 years ago. Updated over 7 years ago.

Status:
Needs Feedback
Priority:
Should have
Category:
Property
Target version:
-
Start date:
2012-02-21
Due date:
% Done:

0%

Estimated time:
PHP Version:
Has patch:
Yes
Complexity:

Description

In the case of models with non-optional constructor arguments, you get an exception when one of those subproperties has an error in the TypeConverter. This can be fixed by changing the following (\TYPO3\FLOW3\Property\PropertyMapper:162)

            $currentPropertyPath[] = $targetPropertyName;
            $targetPropertyValue = $this->doMapping($sourcePropertyValue, $targetPropertyType, $subConfiguration, $currentPropertyPath);
            array_pop($currentPropertyPath);
            if ($targetPropertyValue !== NULL) {
                $convertedChildProperties[$targetPropertyName] = $targetPropertyValue;
            }

To the following:

            $currentPropertyPath[] = $targetPropertyName;
            $targetPropertyValue = $this->doMapping($sourcePropertyValue, $targetPropertyType, $subConfiguration, $currentPropertyPath);
            if ($this->messages->forProperty(implode('.', $currentPropertyPath))->hasErrors()) {
                return NULL;
            }
            array_pop($currentPropertyPath);
            if ($targetPropertyValue !== NULL) {
                $convertedChildProperties[$targetPropertyName] = $targetPropertyValue;
            }
#1

Updated by Kira Backes over 9 years ago

  • Project changed from TYPO3 Flow Base Distribution to TYPO3.Flow
#2

Updated by Kira Backes over 9 years ago

Here is a better solution so you can still get all errors for all properties and you still won’t get an exception even for a lot of nested problems.

Change this (\TYPO3\FLOW3\Property\PropertyMapper:169):

        $result = $typeConverter->convertFrom($source, $targetType, $convertedChildProperties, $configuration);

To:

        if ($this->messages->forProperty(implode('.', $currentPropertyPath))->hasErrors()) {
            return NULL;
        }
        $result = $typeConverter->convertFrom($source, $targetType, $convertedChildProperties, $configuration);

#3

Updated by Kira Backes over 9 years ago

That solution still has a flaw, I can’t see all validation errors no more, because the object validation is missing now.. This seems to be an unsolvable problem with the current system.

#4

Updated by Karsten Dambekalns over 9 years ago

  • Category set to Property
  • Has patch set to Yes
#5

Updated by Christian Müller over 9 years ago

  • Status changed from New to Needs Feedback

Hi,

could you please try https://review.typo3.org/#/c/9606/ with your environment? I am not sure if that works out but couldn't come up with a good testing setup.

#6

Updated by Karsten Dambekalns over 9 years ago

  • Assignee set to Christian Müller
#7

Updated by Bastian Waidelich over 7 years ago

Any news on this one?

Also available in: Atom PDF