From a1424c6bc9eaa9fee90b507e051a17516547f6f2 Mon Sep 17 00:00:00 2001 From: Christian Kuhn <lolli@schwarzbu.ch> Date: Thu, 15 Feb 2024 10:39:00 +0100 Subject: [PATCH] [TASK] Stop runtime caching GU::trimExplode() in DH There is no point to substitute GU::trimExplode() of the rather short TCA 'eval' string by substituting it with an md5() operation plus runtime cache object operations. Both things are most likely similarily quick, and the time consumed by queries in DH is multiple orders of magnitude bigger than this simple operation, a difference is not measurable. Let's thus simplify the code a bit. Resolves: #103125 Releases: main, 12.4 Change-Id: I474d3fbe6b503a99a9129856b0f59c777b171844 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82977 Tested-by: core-ci <typo3@b13.com> Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de> Tested-by: Oliver Klee <typo3-coding@oliverklee.de> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> --- .../core/Classes/DataHandling/DataHandler.php | 29 +++---------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/typo3/sysext/core/Classes/DataHandling/DataHandler.php b/typo3/sysext/core/Classes/DataHandling/DataHandler.php index b44dbc29633b..0ccb1af9d400 100644 --- a/typo3/sysext/core/Classes/DataHandling/DataHandler.php +++ b/typo3/sysext/core/Classes/DataHandling/DataHandler.php @@ -1638,12 +1638,7 @@ class DataHandler implements LoggerAwareInterface if (!$this->validateValueForRequired($tcaFieldConf, $value)) { $valueArray = []; } elseif (isset($tcaFieldConf['eval']) && $tcaFieldConf['eval'] !== '') { - $cacheId = $this->getFieldEvalCacheIdentifier($tcaFieldConf['eval']); - $evalCodesArray = $this->runtimeCache->get($cacheId); - if (!is_array($evalCodesArray)) { - $evalCodesArray = GeneralUtility::trimExplode(',', $tcaFieldConf['eval'], true); - $this->runtimeCache->set($cacheId, $evalCodesArray); - } + $evalCodesArray = GeneralUtility::trimExplode(',', $tcaFieldConf['eval'], true); $valueArray = $this->checkValue_text_Eval($value, $evalCodesArray, $tcaFieldConf['is_in'] ?? ''); } else { $valueArray = ['value' => $value]; @@ -1698,15 +1693,8 @@ class DataHandler implements LoggerAwareInterface $res = ['value' => $value]; } else { // Process evaluation settings: - $cacheId = $this->getFieldEvalCacheIdentifier($tcaFieldConf['eval']); - $evalCodesArray = $this->runtimeCache->get($cacheId); - if (!is_array($evalCodesArray)) { - $evalCodesArray = GeneralUtility::trimExplode(',', $tcaFieldConf['eval'], true); - $this->runtimeCache->set($cacheId, $evalCodesArray); - } - + $evalCodesArray = GeneralUtility::trimExplode(',', $tcaFieldConf['eval'], true); $res = $this->checkValue_input_Eval((string)$value, $evalCodesArray, $tcaFieldConf['is_in'] ?? '', $table, $id); - // Process UNIQUE settings: // Field is NOT set for flexForms - which also means that uniqueInPid and unique is NOT available for flexForm fields! Also getUnique should not be done for versioning if ($field && !empty($res['value'])) { @@ -9810,6 +9798,7 @@ class DataHandler implements LoggerAwareInterface */ protected function isNestedElementCallRegistered($table, $id, $identifier) { + // @todo: Stop abusing runtime cache as singleton DTO, needs explicit modeling. $nestedElementCalls = (array)$this->runtimeCache->get($this->cachePrefixNestedElementCalls); return isset($nestedElementCalls[$identifier][$table][$id]); } @@ -9850,6 +9839,7 @@ class DataHandler implements LoggerAwareInterface */ protected function isElementToBeDeleted($table, $id) { + // @todo: Stop abusing runtime cache as singleton DTO, needs explicit modeling. $elementsToBeDeleted = (array)$this->runtimeCache->get('core-datahandler-elementsToBeDeleted'); return isset($elementsToBeDeleted[$table][$id]); } @@ -10021,17 +10011,6 @@ class DataHandler implements LoggerAwareInterface } } - /** - * Return the cache entry identifier for field evals - * - * @param string $additionalIdentifier - * @return string - */ - protected function getFieldEvalCacheIdentifier($additionalIdentifier) - { - return 'core-datahandler-eval-' . md5($additionalIdentifier); - } - /** * @return RelationHandler */ -- GitLab