Bug #34134

PropertyMapper throws unnecessary exception

Added by Kira Backes about 1 year ago. Updated about 1 year ago.

Status:Needs Feedback Start date:2012-02-21
Priority:Should have Due date:
Assignee:Christian Mueller % Done:

0%

Category:Property
Target version:-
PHP Version: Complexity:
Has patch:Yes FLOW3 version affected:Git master
Votes: 1 (View)

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;
            }

History

Updated by Kira Backes about 1 year ago

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

Updated by Kira Backes about 1 year 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);

Updated by Kira Backes about 1 year 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.

Updated by Karsten Dambekalns about 1 year ago

  • Category set to Property
  • Has patch set to Yes

Updated by Christian Mueller about 1 year 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.

Updated by Karsten Dambekalns about 1 year ago

  • Assignee set to Christian Mueller

Also available in: Atom PDF