[BUGFIX] INCLUDE_TYPOSCRIPT condition use correct ConditionMatcher 60/52760/2
authorAndreas Allacher <andreas@allacher.com>
Wed, 22 Mar 2017 07:25:35 +0000 (08:25 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 11 May 2017 11:21:11 +0000 (13:21 +0200)
In order to support all conditions correctly
whether one is in FE or BE the condition
has to be matched against the correct
ConditionMatcher instead of always
using the one for BE.

Releases: master, 8.7, 7.6
Resolves: #80385
Change-Id: Id5e216da40000b408f96822855d97799f254d0fb
Reviewed-on: https://review.typo3.org/52760
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php

index 930811f..9a3c3cd 100644 (file)
@@ -14,12 +14,14 @@ namespace TYPO3\CMS\Core\TypoScript\Parser;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Backend\Configuration\TypoScript\ConditionMatching\ConditionMatcher;
+use TYPO3\CMS\Backend\Configuration\TypoScript\ConditionMatching\ConditionMatcher as BackendConditionMatcher;
+use TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher;
 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\TypoScript\ExtendedTemplateService;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
 use TYPO3\CMS\Core\Utility\PathUtility;
+use TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher as FrontendConditionMatcher;
 
 /**
  * The TypoScript parser
@@ -832,8 +834,15 @@ class TypoScriptParser
                     if ($condition[0] !== '[') {
                         $condition = '[' . $condition . ']';
                     }
-                    /** @var ConditionMatcher $conditionMatcher */
-                    $conditionMatcher = GeneralUtility::makeInstance(ConditionMatcher::class);
+
+                    /** @var AbstractConditionMatcher $conditionMatcher */
+                    $conditionMatcher = null;
+                    if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_FE) {
+                        $conditionMatcher = GeneralUtility::makeInstance(FrontendConditionMatcher::class);
+                    } else {
+                        $conditionMatcher = GeneralUtility::makeInstance(BackendConditionMatcher::class);
+                    }
+
                     // If it didn't match then proceed to the next include, but prepend next normal (not file) part to output string
                     if (!$conditionMatcher->match($condition)) {
                         $newString .= $tsContentsTillNextInclude . LF;