[BUGFIX] Cache in BackendConfigurationManager is not taking pageId into account
authorTymoteusz Motylewski <t.motylewski@gmail.com>
Wed, 7 Nov 2012 08:58:07 +0000 (09:58 +0100)
committerHelmut Hummel <helmut.hummel@typo3.org>
Wed, 14 Nov 2012 23:23:26 +0000 (00:23 +0100)
Cache in BackendConfigurationManager is not taking pageId into account
Thanks to Timo Schmidt for providing the patch.

Change-Id: I55a5eb6bda086af91c5bf3ab621754b1a04d0f1e
Fixes: #42737
Releases: 6.0, 4.7, 1.3
Reviewed-on: http://review.typo3.org/16246
Reviewed-by: Stefan Neufeind
Reviewed-by: Wouter Wolters
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/extbase/Classes/Configuration/BackendConfigurationManager.php

index ea7a170..f1d5582 100644 (file)
@@ -34,7 +34,7 @@ class BackendConfigurationManager extends \TYPO3\CMS\Extbase\Configuration\Abstr
        /**
         * @var array
         */
-       protected $typoScriptSetupCache = NULL;
+       protected $typoScriptSetupCache = array();
 
        /**
         * Returns TypoScript Setup array from current Environment.
@@ -42,26 +42,27 @@ class BackendConfigurationManager extends \TYPO3\CMS\Extbase\Configuration\Abstr
         * @return array the raw TypoScript setup
         */
        public function getTypoScriptSetup() {
-               if ($this->typoScriptSetupCache === NULL) {
+               $pageId = $this->getCurrentPageId();
+
+               if (!array_key_exists($pageId, $this->typoScriptSetupCache)) {
                        $template = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\TemplateService');
                        // do not log time-performance information
                        $template->tt_track = 0;
                        $template->init();
                        // Get the root line
                        $rootline = array();
-                       $pageId = $this->getCurrentPageId();
                        if ($pageId > 0) {
                                /** @var $sysPage \TYPO3\CMS\Frontend\Page\PageRepository */
                                $sysPage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
                                // Get the rootline for the current page
-                               $rootline = $sysPage->getRootLine($this->getCurrentPageId(), '', TRUE);
+                               $rootline = $sysPage->getRootLine($pageId, '', TRUE);
                        }
                        // This generates the constants/config + hierarchy info for the template.
                        $template->runThroughTemplates($rootline, 0);
                        $template->generateConfig();
-                       $this->typoScriptSetupCache = $template->setup;
+                       $this->typoScriptSetupCache[$pageId] = $template->setup;
                }
-               return $this->typoScriptSetupCache;
+               return $this->typoScriptSetupCache[$pageId];
        }
 
        /**
@@ -161,4 +162,4 @@ class BackendConfigurationManager extends \TYPO3\CMS\Extbase\Configuration\Abstr
 }
 
 
-?>
\ No newline at end of file
+?>