[BUGFIX] Expression Language should not crash Backend Modules 02/58102/2
authorBenni Mack <benni@typo3.org>
Fri, 31 Aug 2018 12:18:22 +0000 (14:18 +0200)
committerFrans Saris <franssaris@gmail.com>
Fri, 31 Aug 2018 14:00:41 +0000 (16:00 +0200)
When doing "[page["uid"] >= 284]" in a TypoScript condition, everything works
as expected in Frontend, but in BE it gets messy, as "page" HAS to be an array
to allow to validate this, but page does not always exist.

This comes from a wrong spec, claiming that conditionMatcher->getPage() always
returns an array, which is wrong. So let's make the code return an array all the time.

Resolves: #86062
Releases: master
Change-Id: Ia781c84ffa335fce5ba2d67bbe2997ceab5281b4
Reviewed-on: https://review.typo3.org/58102
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
typo3/sysext/backend/Classes/Configuration/TypoScript/ConditionMatching/ConditionMatcher.php
typo3/sysext/frontend/Classes/Configuration/TypoScript/ConditionMatching/ConditionMatcher.php

index 214e30a..b9cc0f8 100644 (file)
@@ -202,7 +202,7 @@ class ConditionMatcher extends AbstractConditionMatcher
     protected function getPage()
     {
         $pageId = $this->pageId ?? $this->determinePageId();
-        return BackendUtility::getRecord('pages', $pageId);
+        return BackendUtility::getRecord('pages', $pageId) ?? [];
     }
 
     /**
index 0bf5301..f58ffbc 100644 (file)
@@ -266,7 +266,9 @@ class ConditionMatcher extends AbstractConditionMatcher
      */
     protected function getPage()
     {
-        return $this->getTypoScriptFrontendController()->page;
+        return is_array($this->getTypoScriptFrontendController()->page)
+            ? $this->getTypoScriptFrontendController()->page
+            : [];
     }
 
     /**