[BUGFIX] Better caching of TSconfig in BackendUtility for bulk inserts 45/35145/2
authorStephan Großberndt <stephan@grossberndt.de>
Sat, 6 Dec 2014 22:48:57 +0000 (23:48 +0100)
committerMarkus Klein <klein.t3@reelworx.at>
Mon, 8 Dec 2014 00:43:27 +0000 (01:43 +0100)
Changes the cache of pageTSconfig from creating a cached entry for each
page to creating a cached entry for each different TSconfig (including
userTSconfig) and a hash-cache for each page instead.

Resolves: #63629
Releases: master, 6.2
Change-Id: I3e4c70cd46cec26dda8574c058d828ec2e22a385
Reviewed-on: http://review.typo3.org/35145
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/backend/Classes/Configuration/TsConfigParser.php
typo3/sysext/backend/Classes/Utility/BackendUtility.php

index 33d698c..5edc0be 100644 (file)
@@ -52,7 +52,8 @@ class TsConfigParser extends \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser
                        if ($checkMD5 == $storedMD5) {
                                $res = array(
                                        'TSconfig' => $storedData['TSconfig'],
-                                       'cached' => 1
+                                       'cached' => 1,
+                                       'hash' => $hash
                                );
                        } else {
                                $shash = md5($checkMD5 . $hash);
@@ -61,14 +62,16 @@ class TsConfigParser extends \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser
                                        $storedData = $cachedSpec;
                                        $res = array(
                                                'TSconfig' => $storedData['TSconfig'],
-                                               'cached' => 1
+                                               'cached' => 1,
+                                               'hash' => $shash
                                        );
                                } else {
                                        $storeData = $this->parseWithConditions($TStext);
                                        BackendUtility::storeHash($shash, $storeData, $type . '_TSconfig');
                                        $res = array(
                                                'TSconfig' => $storeData['TSconfig'],
-                                               'cached' => 0
+                                               'cached' => 0,
+                                               'hash' => $shash
                                        );
                                }
                        }
@@ -78,7 +81,8 @@ class TsConfigParser extends \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser
                        BackendUtility::storeHash($hash, array($storeData, $md5), $type . '_TSconfig');
                        $res = array(
                                'TSconfig' => $storeData['TSconfig'],
-                               'cached' => 0
+                               'cached' => 0,
+                               'hash' => $hash
                        );
                }
                return $res;
index 912586e..795b464 100644 (file)
@@ -1153,14 +1153,15 @@ class BackendUtility {
         * @see \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser
         */
        static public function getPagesTSconfig($id, $rootLine = NULL, $returnPartArray = FALSE) {
-               static $pagesTSconfig_cache = array();
+               static $pagesTSconfig_cacheReference = array();
+               static $combinedTSconfig_cache = array();
 
                $id = (int)$id;
                if ($returnPartArray === FALSE
                        && $rootLine === NULL
-                       && isset($pagesTSconfig_cache[$id])
+                       && isset($pagesTSconfig_cacheReference[$id])
                ) {
-                       return $pagesTSconfig_cache[$id];
+                       return $combinedTSconfig_cache[$pagesTSconfig_cacheReference[$id]];
                } else {
                        $TSconfig = array();
                        if (!is_array($rootLine)) {
@@ -1191,14 +1192,19 @@ class BackendUtility {
                        if ($res) {
                                $TSconfig = $res['TSconfig'];
                        }
+                       $cacheHash = $res['hash'];
                        // Get User TSconfig overlay
                        $userTSconfig = $GLOBALS['BE_USER']->userTS['page.'];
                        if (is_array($userTSconfig)) {
                                \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($TSconfig, $userTSconfig);
+                               $cacheHash .= '_user' . $GLOBALS['BE_USER']->user['uid'];
                        }
 
                        if ($useCacheForCurrentPageId) {
-                               $pagesTSconfig_cache[$id] = $TSconfig;
+                               if (!isset($combinedTSconfig_cache[$cacheHash])) {
+                                       $combinedTSconfig_cache[$cacheHash] = $TSconfig;
+                               }
+                               $pagesTSconfig_cacheReference[$id] = $cacheHash;
                        }
                }
                return $TSconfig;