[BUGFIX] Add defaultTypoScript to hierachyInfo 38/26738/5
authorPeter Niederlag <netservice@niekom.de>
Fri, 10 Jan 2014 13:16:53 +0000 (14:16 +0100)
committerBenjamin Mack <benni@typo3.org>
Tue, 14 Jan 2014 13:08:45 +0000 (14:08 +0100)
Fixes a problem with the TemplateAnalyzer introduced by #43540

- Always add both defaultTypoScript_setup and defaultTypoScript_constants.
- Add information for defaultTypoScript into hierarchyInfo.

Change-Id: I15ad5f268eb167d6c8f027e1891409d9ead64539
Resolves: #53352
Releases: 6.2, 6.1, 4.7
Reviewed-on: https://review.typo3.org/26738
Reviewed-by: Markus Klein
Reviewed-by: Michiel Roos
Tested-by: Michiel Roos
Reviewed-by: Stefan Neufeind
Reviewed-by: Benjamin Mack
Tested-by: Benjamin Mack
typo3/sysext/core/Classes/TypoScript/TemplateService.php

index e1acdac..3e7a292 100644 (file)
@@ -1628,14 +1628,31 @@ class TemplateService {
         * @see isDefaultTypoScriptAdded
         */
        protected function addDefaultTypoScript() {
-                       // Add default TS for all code types, if not done already
+               // Add default TS for all code types, if not done already
                if (!$this->isDefaultTypoScriptAdded) {
-                       if (!empty($GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_constants'])) {
-                               array_unshift($this->constants, (string)$GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_constants']);
-                       }
-                       if (!empty($GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup'])) {
-                               array_unshift($this->config, (string)$GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup']);
-                       }
+                       // adding default setup and constants
+                       // defaultTypoScript_setup is *very* unlikely to be empty
+                       // the count of elements in ->constants and ->config have to be in sync so we always add *both*
+                       array_unshift($this->constants, (string)$GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_constants']);
+                       array_unshift($this->config, (string)$GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup']);
+                       // prepare a proper entry to hierachyInfo (used by TemplateAnalyzer in BE)
+                       $rootTemplateId = $this->hierarchyInfo[count($this->hierarchyInfo)-1]['templateID'];
+                       $defaultTemplateInfo = array(
+                               'root' => '',
+                               'next' => '',
+                               'clConst' => '',
+                               'clConf' => '',
+                               'templateID' => '_defaultTypoScript_',
+                               'templateParent' => $rootTemplateId,
+                               'title' => 'SYS:TYPO3_CONF_VARS:FE:defaultTypoScript',
+                               'uid' => '_defaultTypoScript_',
+                               'pid' => '',
+                               'configLines' => substr_count((string)$GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup'], LF) + 1
+                       );
+                       // push info to information arrays used in BE by TemplateTools (Analyzer)
+                       array_unshift($this->clearList_const, $defaultTemplateInfo['uid']);
+                       array_unshift($this->clearList_setup, $defaultTemplateInfo['uid']);
+                       array_unshift($this->hierarchyInfo, $defaultTemplateInfo);
                        $this->isDefaultTypoScriptAdded = TRUE;
                }
        }