[TASK] Save 2 calls to the runtime cache in DataHandler 94/54894/2
authorWouter Wolters <typo3@wouterwolters.nl>
Thu, 30 Nov 2017 21:00:34 +0000 (22:00 +0100)
committerBenni Mack <benni@typo3.org>
Fri, 1 Dec 2017 19:21:19 +0000 (20:21 +0100)
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

index a29eb1c..0a2cceb 100644 (file)
@@ -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);
             }