From ff0d2d569c55102ed109693cd5f61a083cc6e972 Mon Sep 17 00:00:00 2001
From: Wouter Wolters <typo3@wouterwolters.nl>
Date: Thu, 30 Nov 2017 22:00:34 +0100
Subject: [PATCH] [TASK] Save 2 calls to the runtime cache in DataHandler

By just getting the value and checking what is returned instead of
calling the runtime cache twice for each call

Resolves: #83181
Releases: master
Change-Id: Ic5802bf57faa5f8e38c35f9405918d5076697332
Reviewed-on: https://review.typo3.org/54894
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
---
 typo3/sysext/core/Classes/DataHandling/DataHandler.php | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/typo3/sysext/core/Classes/DataHandling/DataHandler.php b/typo3/sysext/core/Classes/DataHandling/DataHandler.php
index a29eb1c87327..0a2ccebdca63 100644
--- a/typo3/sysext/core/Classes/DataHandling/DataHandler.php
+++ b/typo3/sysext/core/Classes/DataHandling/DataHandler.php
@@ -1785,9 +1785,8 @@ class DataHandler implements LoggerAwareInterface
     {
         if (isset($tcaFieldConf['eval']) && $tcaFieldConf['eval'] !== '') {
             $cacheId = $this->getFieldEvalCacheIdentifier($tcaFieldConf['eval']);
-            if ($this->runtimeCache->has($cacheId)) {
-                $evalCodesArray = $this->runtimeCache->get($cacheId);
-            } else {
+            $evalCodesArray = $this->runtimeCache->get($cacheId);
+            if (!is_array($evalCodesArray)) {
                 $evalCodesArray = GeneralUtility::trimExplode(',', $tcaFieldConf['eval'], true);
                 $this->runtimeCache->set($cacheId, $evalCodesArray);
             }
@@ -1870,9 +1869,8 @@ class DataHandler implements LoggerAwareInterface
         } else {
             // Process evaluation settings:
             $cacheId = $this->getFieldEvalCacheIdentifier($tcaFieldConf['eval']);
-            if ($this->runtimeCache->has($cacheId)) {
-                $evalCodesArray = $this->runtimeCache->get($cacheId);
-            } else {
+            $evalCodesArray = $this->runtimeCache->get($cacheId);
+            if (!is_array($evalCodesArray)) {
                 $evalCodesArray = GeneralUtility::trimExplode(',', $tcaFieldConf['eval'], true);
                 $this->runtimeCache->set($cacheId, $evalCodesArray);
             }
-- 
GitLab