[!!!][TASK] Spread TypeConverter priorities 61/47361/4
authorBernhard Kraft <kraftb@think-open.at>
Tue, 22 Mar 2016 19:11:02 +0000 (20:11 +0100)
committerSusanne Moog <susanne.moog@typo3.org>
Wed, 7 Dec 2016 15:08:43 +0000 (16:08 +0100)
The priorities of the "TypeConverter" classes are densly packed.

With the current situation it is not possible to create a custom
TypeConverter with higher priority than "ObjectConverter" but
lower than "PersistentObjectConverter".

Resolves: #75232
Releases: master
Change-Id: If620f927fad54118c71347bc797b93397815a39f
Reviewed-on: https://review.typo3.org/47361
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
22 files changed:
typo3/sysext/core/Documentation/Changelog/master/Important-75232-SpreadTypeConverterPriorities.rst [new file with mode: 0644]
typo3/sysext/extbase/Classes/Property/PropertyMapper.php
typo3/sysext/extbase/Classes/Property/TypeConverter/AbstractFileCollectionConverter.php
typo3/sysext/extbase/Classes/Property/TypeConverter/AbstractFileFolderConverter.php
typo3/sysext/extbase/Classes/Property/TypeConverter/ArrayConverter.php
typo3/sysext/extbase/Classes/Property/TypeConverter/BooleanConverter.php
typo3/sysext/extbase/Classes/Property/TypeConverter/CoreTypeConverter.php
typo3/sysext/extbase/Classes/Property/TypeConverter/DateTimeConverter.php
typo3/sysext/extbase/Classes/Property/TypeConverter/FloatConverter.php
typo3/sysext/extbase/Classes/Property/TypeConverter/IntegerConverter.php
typo3/sysext/extbase/Classes/Property/TypeConverter/ObjectConverter.php
typo3/sysext/extbase/Classes/Property/TypeConverter/ObjectStorageConverter.php
typo3/sysext/extbase/Classes/Property/TypeConverter/PersistentObjectConverter.php
typo3/sysext/extbase/Classes/Property/TypeConverter/StringConverter.php
typo3/sysext/extbase/Tests/Unit/Property/TypeConverter/ArrayConverterTest.php
typo3/sysext/extbase/Tests/Unit/Property/TypeConverter/BooleanConverterTest.php
typo3/sysext/extbase/Tests/Unit/Property/TypeConverter/DateTimeConverterTest.php
typo3/sysext/extbase/Tests/Unit/Property/TypeConverter/FloatConverterTest.php
typo3/sysext/extbase/Tests/Unit/Property/TypeConverter/IntegerConverterTest.php
typo3/sysext/extbase/Tests/Unit/Property/TypeConverter/ObjectConverterTest.php
typo3/sysext/extbase/Tests/Unit/Property/TypeConverter/PersistentObjectConverterTest.php
typo3/sysext/extbase/Tests/Unit/Property/TypeConverter/StringConverterTest.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Important-75232-SpreadTypeConverterPriorities.rst b/typo3/sysext/core/Documentation/Changelog/master/Important-75232-SpreadTypeConverterPriorities.rst
new file mode 100644 (file)
index 0000000..0973493
--- /dev/null
@@ -0,0 +1,16 @@
+.. include:: ../../Includes.txt
+
+===================================================
+Important: #75232 - Spread TypeConverter priorities
+===================================================
+
+See :issue:`75232`
+
+Description
+===========
+
+The priorities of the "TypeConverter" classes were quite packed. To be able to register own type converters between, before and after the core converters the priorities were spread from 0, 1 and 2 to 10 and 20.
+
+If you register your own TypeConverter(s) make sure they are using the right priority.
+
+.. index:: PHP-API
\ No newline at end of file
index 94a1b08..2c5f70f 100644 (file)
@@ -319,7 +319,7 @@ class PropertyMapper implements \TYPO3\CMS\Core\SingletonInterface
         if (!is_array($converters)) {
             return null;
         }
-        krsort($converters);
+        krsort($converters, SORT_NUMERIC);
         reset($converters);
         /** @var AbstractTypeConverter $converter */
         foreach ($converters as $converter) {
index 5ef6abd..6cdce83 100644 (file)
@@ -24,7 +24,7 @@ abstract class AbstractFileCollectionConverter extends \TYPO3\CMS\Extbase\Proper
     /**
      * @var int
      */
-    protected $priority = 1;
+    protected $priority = 10;
 
     /**
      * @var string
index 2c841eb..1c01c8a 100644 (file)
@@ -24,7 +24,7 @@ abstract class AbstractFileFolderConverter extends \TYPO3\CMS\Extbase\Property\T
     /**
      * @var int
      */
-    protected $priority = 1;
+    protected $priority = 10;
 
     /**
      * @var string
index 191b22d..bc96d1e 100644 (file)
@@ -40,7 +40,7 @@ class ArrayConverter extends \TYPO3\CMS\Extbase\Property\TypeConverter\AbstractT
     /**
      * @var int
      */
-    protected $priority = 1;
+    protected $priority = 10;
 
     /**
      * We can only convert empty strings to array or array to array.
index a7af709..cb31c77 100644 (file)
@@ -40,7 +40,7 @@ class BooleanConverter extends \TYPO3\CMS\Extbase\Property\TypeConverter\Abstrac
     /**
      * @var int
      */
-    protected $priority = 1;
+    protected $priority = 10;
 
     /**
      * Actually convert from $source to $targetType
index b15df00..da7090e 100644 (file)
@@ -44,7 +44,7 @@ class CoreTypeConverter extends \TYPO3\CMS\Extbase\Property\TypeConverter\Abstra
     /**
      * @var int
      */
-    protected $priority = 1;
+    protected $priority = 10;
 
     /**
      * @param mixed $source
index 36cdde2..0a0f155 100644 (file)
@@ -88,7 +88,7 @@ class DateTimeConverter extends \TYPO3\CMS\Extbase\Property\TypeConverter\Abstra
     /**
      * @var int
      */
-    protected $priority = 1;
+    protected $priority = 10;
 
     /**
      * If conversion is possible.
index 91572a8..b13be33 100644 (file)
@@ -52,7 +52,7 @@ class FloatConverter extends \TYPO3\CMS\Extbase\Property\TypeConverter\AbstractT
     /**
      * @var int
      */
-    protected $priority = 1;
+    protected $priority = 10;
 
     /**
      * Actually convert from $source to $targetType, by doing a typecast.
index bd347f0..1f2cc59 100644 (file)
@@ -40,7 +40,7 @@ class IntegerConverter extends \TYPO3\CMS\Extbase\Property\TypeConverter\Abstrac
     /**
      * @var int
      */
-    protected $priority = 1;
+    protected $priority = 10;
 
     /**
      * Actually convert from $source to $targetType, in fact a noop here.
index c5ad510..a87e7ab 100644 (file)
@@ -50,7 +50,7 @@ class ObjectConverter extends AbstractTypeConverter implements \TYPO3\CMS\Core\S
     /**
      * @var int
      */
-    protected $priority = 0;
+    protected $priority = 10;
 
     /**
      * @var \TYPO3\CMS\Extbase\Object\Container\Container
index c73d5b9..fb4ca3f 100644 (file)
@@ -42,7 +42,7 @@ class ObjectStorageConverter extends AbstractTypeConverter
     /**
      * @var int
      */
-    protected $priority = 1;
+    protected $priority = 10;
 
     /**
      * Actually convert from $source to $targetType, taking into account the fully
index 5788850..d5338b0 100644 (file)
@@ -59,7 +59,7 @@ class PersistentObjectConverter extends ObjectConverter
     /**
      * @var int
      */
-    protected $priority = 1;
+    protected $priority = 20;
 
     /**
      * @var \TYPO3\CMS\Extbase\Persistence\PersistenceManagerInterface
index 6fc1f47..49fb577 100644 (file)
@@ -40,7 +40,7 @@ class StringConverter extends \TYPO3\CMS\Extbase\Property\TypeConverter\Abstract
     /**
      * @var int
      */
-    protected $priority = 1;
+    protected $priority = 10;
 
     /**
      * Actually convert from $source to $targetType, taking into account the fully
index 480fc9b..e8b337d 100644 (file)
@@ -43,7 +43,7 @@ class ArrayConverterTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         $this->assertEquals(['array', 'string'], $this->converter->getSupportedSourceTypes(), 'Source types do not match');
         $this->assertEquals('array', $this->converter->getSupportedTargetType(), 'Target type does not match');
-        $this->assertEquals(1, $this->converter->getPriority(), 'Priority does not match');
+        $this->assertEquals(10, $this->converter->getPriority(), 'Priority does not match');
     }
 
     /**
index 382118a..cee9276 100644 (file)
@@ -43,7 +43,7 @@ class BooleanConverterTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         $this->assertEquals(['boolean', 'string'], $this->converter->getSupportedSourceTypes(), 'Source types do not match');
         $this->assertEquals('boolean', $this->converter->getSupportedTargetType(), 'Target type does not match');
-        $this->assertEquals(1, $this->converter->getPriority(), 'Priority does not match');
+        $this->assertEquals(10, $this->converter->getPriority(), 'Priority does not match');
     }
 
     /**
index 138aea8..bbf6298 100644 (file)
@@ -46,7 +46,7 @@ class DateTimeConverterTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         $this->assertEquals(['string', 'integer', 'array'], $this->converter->getSupportedSourceTypes(), 'Source types do not match');
         $this->assertEquals('DateTime', $this->converter->getSupportedTargetType(), 'Target type does not match');
-        $this->assertEquals(1, $this->converter->getPriority(), 'Priority does not match');
+        $this->assertEquals(10, $this->converter->getPriority(), 'Priority does not match');
     }
 
     /** String to DateTime testcases  **/
index 1776058..a4a5249 100644 (file)
@@ -43,7 +43,7 @@ class FloatConverterTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         $this->assertEquals(['float', 'integer', 'string'], $this->converter->getSupportedSourceTypes(), 'Source types do not match');
         $this->assertEquals('float', $this->converter->getSupportedTargetType(), 'Target type does not match');
-        $this->assertEquals(1, $this->converter->getPriority(), 'Priority does not match');
+        $this->assertEquals(10, $this->converter->getPriority(), 'Priority does not match');
     }
 
     /**
index 2d17808..c9eadf2 100644 (file)
@@ -43,7 +43,7 @@ class IntegerConverterTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         $this->assertEquals(['integer', 'string'], $this->converter->getSupportedSourceTypes(), 'Source types do not match');
         $this->assertEquals('integer', $this->converter->getSupportedTargetType(), 'Target type does not match');
-        $this->assertEquals(1, $this->converter->getPriority(), 'Priority does not match');
+        $this->assertEquals(10, $this->converter->getPriority(), 'Priority does not match');
     }
 
     /**
index 34309dc..ba87e36 100644 (file)
@@ -72,7 +72,7 @@ class ObjectConverterTest extends UnitTestCase
     {
         $this->assertEquals(['array'], $this->converter->getSupportedSourceTypes(), 'Source types do not match');
         $this->assertEquals('object', $this->converter->getSupportedTargetType(), 'Target type does not match');
-        $this->assertEquals(0, $this->converter->getPriority(), 'Priority does not match');
+        $this->assertEquals(10, $this->converter->getPriority(), 'Priority does not match');
     }
 
     /**
index 7efc3e7..e9e1257 100644 (file)
@@ -98,7 +98,7 @@ class PersistentObjectConverterTest extends UnitTestCase
     {
         $this->assertEquals(['integer', 'string', 'array'], $this->converter->getSupportedSourceTypes(), 'Source types do not match');
         $this->assertEquals('object', $this->converter->getSupportedTargetType(), 'Target type does not match');
-        $this->assertEquals(1, $this->converter->getPriority(), 'Priority does not match');
+        $this->assertEquals(20, $this->converter->getPriority(), 'Priority does not match');
     }
 
     /**
index 1863cb7..2875192 100644 (file)
@@ -43,7 +43,7 @@ class StringConverterTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         $this->assertEquals(['string', 'integer'], $this->converter->getSupportedSourceTypes(), 'Source types do not match');
         $this->assertEquals('string', $this->converter->getSupportedTargetType(), 'Target type does not match');
-        $this->assertEquals(1, $this->converter->getPriority(), 'Priority does not match');
+        $this->assertEquals(10, $this->converter->getPriority(), 'Priority does not match');
     }
 
     /**