From abf0532b350c86b1998fc28e372a076fff33e06c Mon Sep 17 00:00:00 2001
From: Susanne Moog <susanne.moog@typo3.com>
Date: Tue, 22 Aug 2017 12:10:50 +0200
Subject: [PATCH] [BUGFIX] Do not renumber unique keys in ArrayUtility

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        | 2 +-
 typo3/sysext/core/Tests/Unit/Utility/ArrayUtilityTest.php | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/typo3/sysext/core/Classes/Utility/ArrayUtility.php b/typo3/sysext/core/Classes/Utility/ArrayUtility.php
index 79254a9f5071..b9efd5e07cb6 100644
--- a/typo3/sysext/core/Classes/Utility/ArrayUtility.php
+++ b/typo3/sysext/core/Classes/Utility/ArrayUtility.php
@@ -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;
             }
diff --git a/typo3/sysext/core/Tests/Unit/Utility/ArrayUtilityTest.php b/typo3/sysext/core/Tests/Unit/Utility/ArrayUtilityTest.php
index 767d4e5d9687..2c2771e84e13 100644
--- a/typo3/sysext/core/Tests/Unit/Utility/ArrayUtilityTest.php
+++ b/typo3/sysext/core/Tests/Unit/Utility/ArrayUtilityTest.php
@@ -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',
-- 
GitLab