[BUGFIX] PropertyMapper now normalizes simple types 28/39628/3
authorWouter Wolters <typo3@wouterwolters.nl>
Wed, 20 May 2015 09:00:18 +0000 (11:00 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Thu, 4 Jun 2015 13:29:47 +0000 (15:29 +0200)
This fixes a bug where the property mapper was unable to find a
valid typeconverter for properties annotated with int or bool.

Resolves: #67044
Releases: master,6.2
Change-Id: Ie15b6d83e70c5857a09f1d8baa21c168924d63b4
Reviewed-on: http://review.typo3.org/39628
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/extbase/Classes/Property/PropertyMapper.php
typo3/sysext/extbase/Tests/Unit/Property/PropertyMapperTest.php

index 5adb82f..c28bcd7 100644 (file)
@@ -21,6 +21,7 @@ namespace TYPO3\CMS\Extbase\Property;
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
 use TYPO3\CMS\Extbase\Property\TypeConverter\AbstractTypeConverter;
+use TYPO3\CMS\Extbase\Utility\TypeHandlingUtility;
 
 /**
  * The Property Mapper transforms simple types (arrays, strings, integers, floats, booleans) to objects or other simple types.
@@ -209,9 +210,11 @@ class PropertyMapper implements \TYPO3\CMS\Core\SingletonInterface {
                // This compatibility layer will be removed with 7.0
                $targetType = \TYPO3\CMS\Core\Core\ClassLoader::getClassNameForAlias($targetType);
 
+               $targetType = TypeHandlingUtility::normalizeType($targetType);
+
                $converter = NULL;
 
-               if (\TYPO3\CMS\Extbase\Utility\TypeHandlingUtility::isSimpleType($targetType)) {
+               if (TypeHandlingUtility::isSimpleType($targetType)) {
                        if (isset($this->typeConverters[$sourceType][$targetType])) {
                                $converter = $this->findEligibleConverterWithHighestPriority($this->typeConverters[$sourceType][$targetType], $source, $targetType);
                        }
index 1cf6081..075060a 100644 (file)
@@ -126,27 +126,38 @@ class PropertyMapperTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         */
        public function dataProviderForFindTypeConverter() {
                return array(
-                       array(
-                               'someStringSource',
-                               'string',
-                               array(
+                       array('someStringSource', 'string', array(
+                               'string' => array(
                                        'string' => array(
-                                               'string' => array(
-                                                       10 => $this->getMockTypeConverter('string2string,prio10'),
-                                                       1 => $this->getMockTypeConverter('string2string,prio1')
-                                               )
+                                               10 => $this->getMockTypeConverter('string2string,prio10'),
+                                               1 => $this->getMockTypeConverter('string2string,prio1'),
                                        )
-                               ),
-                               'string2string,prio10'
+                               )), 'string2string,prio10'
                        ),
                        array(array('some' => 'array'), 'string', array(
                                'array' => array(
                                        'string' => array(
                                                10 => $this->getMockTypeConverter('array2string,prio10'),
-                                               1 => $this->getMockTypeConverter('array2string,prio1')
+                                               1 => $this->getMockTypeConverter('array2string,prio1'),
                                        )
-                               )
-                       ), 'array2string,prio10')
+                               )), 'array2string,prio10'
+                       ),
+                       array('someStringSource', 'bool', array(
+                               'string' => array(
+                                       'boolean' => array(
+                                               10 => $this->getMockTypeConverter('string2boolean,prio10'),
+                                               1 => $this->getMockTypeConverter('string2boolean,prio1'),
+                                       )
+                               )), 'string2boolean,prio10'
+                       ),
+                       array('someStringSource', 'int', array(
+                               'string' => array(
+                                       'integer' => array(
+                                               10 => $this->getMockTypeConverter('string2integer,prio10'),
+                                               1 => $this->getMockTypeConverter('string2integer,prio1'),
+                                       ),
+                               )), 'string2integer,prio10'
+                       )
                );
        }