[BUGFIX] INCLUDE_TYPOSCRIPT condition use correct ConditionMatcher 61/52761/2
authorAndreas Allacher <andreas@allacher.com>
Wed, 22 Mar 2017 07:25:35 +0000 (08:25 +0100)
committerJan Helke <typo3@helke.de>
Thu, 11 May 2017 11:22:13 +0000 (13:22 +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/52761
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
typo3/sysext/core/Classes/TypoScript/Parser/TypoScriptParser.php

index f99aeee..9831957 100644 (file)
@@ -14,13 +14,15 @@ 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\Core\Utility\StringUtility;
+use TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher as FrontendConditionMatcher;
 
 /**
  * The TypoScript parser
@@ -840,8 +842,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;