From 4cd1a4d06f65d039a773a5bc3186ea0486b98662 Mon Sep 17 00:00:00 2001
From: Oliver Hader <oliver@typo3.org>
Date: Thu, 14 Apr 2016 14:22:26 +0200
Subject: [PATCH] [TASK] Remove persistent cache in GeneralUtility::xml2array

The method GeneralUtility::xml2array uses a runtime cache and in addition
a persistent database cache. The database cache is triggered using the
"cache_hash" method in PageRepository, which is a frontend only component.
Since this approach is binding the common layer with the frontend layer,
this dependency is removed.

Resolves: #75609
Releases: master
Change-Id: I43bd92df6570502abbb5714b217f3ff0e32a588c
Reviewed-on: https://review.typo3.org/47663
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
---
 .../Unit/Form/FormDataProvider/TcaSelectItemsTest.php     | 5 -----
 typo3/sysext/core/Classes/Utility/GeneralUtility.php      | 8 +-------
 2 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectItemsTest.php b/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectItemsTest.php
index 0bc4d41f1a66..4fdc525be055 100644
--- a/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectItemsTest.php
+++ b/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaSelectItemsTest.php
@@ -576,11 +576,6 @@ class TcaSelectItemsTest extends UnitTestCase
         $languageService->loadSingleTableDescription(Argument::cetera())->willReturn(null);
         $languageService->sL(Argument::cetera())->willReturnArgument(0);
 
-        // Needed to suppress a cache in xml2array
-        /** @var DatabaseConnection|ObjectProphecy $database */
-        $database = $this->prophesize(DatabaseConnection::class);
-        $GLOBALS['TYPO3_DB'] = $database->reveal();
-
         $expectedItems = [
             0 => [
                 0 => 'fooTableTitle aFlexFieldTitle dummy',
diff --git a/typo3/sysext/core/Classes/Utility/GeneralUtility.php b/typo3/sysext/core/Classes/Utility/GeneralUtility.php
index 473dac636a1b..6d4883ae8027 100755
--- a/typo3/sysext/core/Classes/Utility/GeneralUtility.php
+++ b/typo3/sysext/core/Classes/Utility/GeneralUtility.php
@@ -1775,13 +1775,7 @@ class GeneralUtility
         if (!empty($firstLevelCache[$identifier])) {
             $array = $firstLevelCache[$identifier];
         } else {
-            // Look up in second level cache
-            // @todo: Is this cache really required? It basically substitutes a little cpu work with a db query?
-            $array = PageRepository::getHash($identifier, 0);
-            if (!is_array($array)) {
-                $array = self::xml2arrayProcess($string, $NSprefix, $reportDocTag);
-                PageRepository::storeHash($identifier, $array, 'ident_xml2array');
-            }
+            $array = self::xml2arrayProcess($string, $NSprefix, $reportDocTag);
             // Store content in first level cache
             $firstLevelCache[$identifier] = $array;
         }
-- 
GitLab