[BUGFIX] Do not renumber unique keys in ArrayUtility 67/53767/3
authorSusanne Moog <susanne.moog@typo3.com>
Tue, 22 Aug 2017 10:10:50 +0000 (12:10 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 22 Aug 2017 11:08:48 +0000 (13:08 +0200)
In various places throughout the core we are using timestamps followed
by a dot as unique identifiers for array keys (for example the avatar
service is registered that way). The ArrayUtility renumbering function
renumbers these keys on writing configuration, meaning that you cannot
overwrite services registered like that via the configuration manager.

ArrayUtility should not re-order strings containing a number ending with
a single dot.

Change-Id: I7dc1625cfdbab6704df87a8cc06f331d92992d24
Releases: master
Resolves: #82155
Reviewed-on: https://review.typo3.org/53767
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Tested-by: Mathias Brodala <mbrodala@pagemachine.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/Utility/ArrayUtility.php
typo3/sysext/core/Tests/Unit/Utility/ArrayUtilityTest.php

index 79254a9..b9efd5e 100644 (file)
@@ -571,7 +571,7 @@ class ArrayUtility
         $level++;
         $allKeysAreNumeric = true;
         foreach ($array as $key => $_) {
-            if (is_numeric($key) === false) {
+            if (is_numeric($key) === false || (is_string($key) && StringUtility::endsWith($key, '.'))) {
                 $allKeysAreNumeric = false;
                 break;
             }
index 767d4e5..2c2771e 100644 (file)
@@ -1516,6 +1516,10 @@ class ArrayUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
                 [0 => 'Zero', '1' => 'One', 'Two' => 'Two'],
                 [0 => 'Zero', '1' => 'One', 'Two' => 'Two'],
             ],
+            'returns unchanged if keys end with a dot' => [
+                ['2.' => 'Two', '1.' => 'One', '0.' => 'Zero'],
+                ['2.' => 'Two', '1.' => 'One', '0.' => 'Zero'],
+            ],
             'return self with nested numerically keyed array' => [
                 [
                     'One',