[BUGFIX] EXT:form - use context specific configuration cache 66/55266/2
authorRalf Zimmermann <ralf.zimmermann@tritum.de>
Tue, 2 Jan 2018 11:59:52 +0000 (12:59 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 4 Jan 2018 12:59:45 +0000 (13:59 +0100)
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/55266
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/form/Classes/Mvc/Configuration/ConfigurationManager.php

index 502c39a..d68e1c0 100644 (file)
@@ -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
         );
     }