From 1c831ba51a98106253f17108af7018fa5d4fc1aa Mon Sep 17 00:00:00 2001 From: Ralf Zimmermann <ralf.zimmermann@tritum.de> Date: Tue, 2 Jan 2018 12:59:52 +0100 Subject: [PATCH] [BUGFIX] EXT:form - use context specific configuration cache Cache the EXT:form configuration depending on the YAML files which are loaded. Resolves: #83311 Releases: master,8.7 Change-Id: Ib612e7638f5b5ad0ddc08c17e3d3b1e645967304 Reviewed-on: https://review.typo3.org/55240 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Reviewed-by: Reiner Teubner <rteubner@me.com> Tested-by: Reiner Teubner <rteubner@me.com> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> --- .../Configuration/ConfigurationManager.php | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/typo3/sysext/form/Classes/Mvc/Configuration/ConfigurationManager.php b/typo3/sysext/form/Classes/Mvc/Configuration/ConfigurationManager.php index f8291b7a3e2e..a002c6536cc5 100644 --- a/typo3/sysext/form/Classes/Mvc/Configuration/ConfigurationManager.php +++ b/typo3/sysext/form/Classes/Mvc/Configuration/ConfigurationManager.php @@ -95,16 +95,19 @@ class ConfigurationManager extends ExtbaseConfigurationManager implements Config } $ucFirstExtensioName = ucfirst($extensionName); - $yamlSettings = $this->getYamlSettingsFromCache($extensionName); - if (!empty($yamlSettings)) { - return $this->overrideConfigurationByTypoScript($yamlSettings, $extensionName); - } - $typoscriptSettings = $this->getTypoScriptSettings($extensionName); $yamlSettingsFilePaths = isset($typoscriptSettings['yamlConfigurations']) ? ArrayUtility::sortArrayWithIntegerKeys($typoscriptSettings['yamlConfigurations']) : []; + + $cacheKeySuffix = $extensionName . md5(json_encode($yamlSettingsFilePaths)); + + $yamlSettings = $this->getYamlSettingsFromCache($cacheKeySuffix); + if (!empty($yamlSettings)) { + return $this->overrideConfigurationByTypoScript($yamlSettings, $extensionName); + } + $yamlSettings = InheritancesResolverService::create($this->yamlSource->load($yamlSettingsFilePaths)) ->getResolvedConfiguration(); @@ -113,7 +116,7 @@ class ConfigurationManager extends ExtbaseConfigurationManager implements Config ? $yamlSettings['TYPO3']['CMS'][$ucFirstExtensioName] : []; $yamlSettings = ArrayUtility::sortArrayWithIntegerKeysRecursive($yamlSettings); - $this->setYamlSettingsIntoCache($extensionName, $yamlSettings); + $this->setYamlSettingsIntoCache($cacheKeySuffix, $yamlSettings); return $this->overrideConfigurationByTypoScript($yamlSettings, $extensionName); } @@ -152,35 +155,35 @@ class ConfigurationManager extends ExtbaseConfigurationManager implements Config } /** - * @param string $extensionName + * @param string $cacheKeySuffix * @return string */ - protected function getConfigurationCacheKey(string $extensionName): string + protected function getConfigurationCacheKey(string $cacheKeySuffix): string { - return strtolower(self::CONFIGURATION_TYPE_YAML_SETTINGS . '_' . $extensionName); + return strtolower(self::CONFIGURATION_TYPE_YAML_SETTINGS . '_' . $cacheKeySuffix); } /** - * @param string $extensionName + * @param string $cacheKeySuffix * @return mixed */ - protected function getYamlSettingsFromCache(string $extensionName) + protected function getYamlSettingsFromCache(string $cacheKeySuffix) { return $this->getCacheFrontend()->get( - $this->getConfigurationCacheKey($extensionName) + $this->getConfigurationCacheKey($cacheKeySuffix) ); } /** - * @param string $extensionName + * @param string $cacheKeySuffix * @param array $yamlSettings */ protected function setYamlSettingsIntoCache( - string $extensionName, + string $cacheKeySuffix, array $yamlSettings ) { $this->getCacheFrontend()->set( - $this->getConfigurationCacheKey($extensionName), + $this->getConfigurationCacheKey($cacheKeySuffix), $yamlSettings ); } -- GitLab