[TASK] Include constants in TypoScript cache 04/51304/3
authorBenni Mack <benni@typo3.org>
Fri, 13 Jan 2017 09:48:12 +0000 (10:48 +0100)
committerAndreas Fernandez <typo3@scripting-base.de>
Mon, 16 Jan 2017 08:13:43 +0000 (09:13 +0100)
In order to work with available constants in TypoScript in Frontend
the parsed TypoScript constants are included in the cache entries
as well.

This ensures a more consistent behaviour of available information
for the TYPO3 Frontend.

This was previously set via $this->backend_info which was
set to "true" in the TYPO3 Backend.

Resolves: #79307
Releases: master
Change-Id: I5f5e024c8df51c4fd43b7bc607855b9b21ebb1dd
Reviewed-on: https://review.typo3.org/51304
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/core/Classes/TypoScript/ExtendedTemplateService.php
typo3/sysext/core/Classes/TypoScript/TemplateService.php

index f0d5176..b91c03e 100644 (file)
@@ -107,11 +107,6 @@ class ExtendedTemplateService extends TemplateService
     ];
 
     /**
-     * @var bool
-     */
-    public $backend_info = true;
-
-    /**
      * Tsconstanteditor
      *
      * @var int
index 1e99a47..56dcae6 100644 (file)
@@ -79,11 +79,6 @@ class TemplateService
     public $matchAll = false;
 
     /**
-     * @var bool
-     */
-    public $backend_info = false;
-
-    /**
      * Externally set breakpoints (used by Backend Modules)
      *
      * @var int
@@ -474,7 +469,8 @@ class TemplateService
     public function start($theRootLine)
     {
         if (is_array($theRootLine)) {
-            $setupData = '';
+            $constantsData = [];
+            $setupData = [];
             $cacheIdentifier = '';
             // Flag that indicates that the existing data in cache_pagesection
             // could be used (this is the case if $TSFE->all is set, and the
@@ -521,10 +517,15 @@ class TemplateService
             }
             if ($cacheIdentifier) {
                 // Get TypoScript setup array
-                $setupData = $this->getCacheEntry($cacheIdentifier);
+                $cachedData = $this->getCacheEntry($cacheIdentifier);
+                if (is_array($cachedData)) {
+                    $constantsData = $cachedData['constants'];
+                    $setupData = $cachedData['setup'];
+                }
             }
-            if (is_array($setupData) && !$this->forceTemplateParsing) {
-                // If TypoScript setup structure was cached we unserialize it here:
+            if (!empty($setupData) && !$this->forceTemplateParsing) {
+                // TypoScript constants + setup are found in the cache
+                $this->setup_constants = $constantsData;
                 $this->setup = $setupData;
                 if ($this->tt_track) {
                     $this->getTimeTracker()->setTSlogMessage('Using cached TS template data');
@@ -546,7 +547,7 @@ class TemplateService
                 ksort($cc);
                 $cacheIdentifier = md5(serialize($cc));
                 // This stores the data.
-                $this->setCacheEntry($cacheIdentifier, $this->setup, 'TS_TEMPLATE');
+                $this->setCacheEntry($cacheIdentifier, ['constants' => $this->setup_constants, 'setup' => $this->setup], 'TS_TEMPLATE');
                 if ($this->tt_track) {
                     $this->getTimeTracker()->setTSlogMessage('TS template size, serialized: ' . strlen(serialize($this->setup)) . ' bytes');
                 }
@@ -1106,10 +1107,8 @@ class TemplateService
         $this->parserErrors['config'] = $config->errors;
         // Transfer the TypoScript array from the parser object to the internal $this->setup array:
         $this->setup = $config->setup;
-        if ($this->backend_info) {
-            // Used for backend purposes only
-            $this->setup_constants = $constants->setup;
-        }
+        // Do the same for the constants
+        $this->setup_constants = $constants->setup;
         // ****************************************************************
         // Final processing of the $this->setup TypoScript Template array
         // Basically: This is unsetting/setting of certain reserved keys.