[BUGFIX] EvaluteDisplayCondition should throw proper error message 36/58736/2
authorBenni Mack <benni@typo3.org>
Sat, 29 Sep 2018 23:42:41 +0000 (01:42 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sat, 27 Oct 2018 19:53:36 +0000 (21:53 +0200)
When an extension author writes a display condition in TCA and
by incident uses a wrong format for the displayCondition (see ticket)
the strtoupper fails due to the lack of an associative array
because it's a numeric-key array.

An additional check fixes the issue.

Resolves: #79692
Releases: master, 8.7
Change-Id: I4455bdc908e0be1a373f86680e718e876aa5ddd7
Reviewed-on: https://review.typo3.org/58736
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Tested-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/backend/Classes/Form/FormDataProvider/EvaluateDisplayConditions.php
typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/EvaluateDisplayConditionsTest.php

index bcf5940..2ee3290 100644 (file)
@@ -202,7 +202,7 @@ class EvaluateDisplayConditions implements FormDataProviderInterface
             $conditionArray = $this->parseSingleConditionString($condition, $databaseRow, $flexContext);
         } elseif (is_array($condition)) {
             foreach ($condition as $logicalOperator => $groupedDisplayConditions) {
             $conditionArray = $this->parseSingleConditionString($condition, $databaseRow, $flexContext);
         } elseif (is_array($condition)) {
             foreach ($condition as $logicalOperator => $groupedDisplayConditions) {
-                $logicalOperator = strtoupper($logicalOperator);
+                $logicalOperator = strtoupper(is_string($logicalOperator) ? $logicalOperator : '');
                 if (($logicalOperator !== 'AND' && $logicalOperator !== 'OR') || !is_array($groupedDisplayConditions)) {
                     throw new \RuntimeException(
                         'Multiple conditions must have boolean operator "OR" or "AND", "' . $logicalOperator . '" given.',
                 if (($logicalOperator !== 'AND' && $logicalOperator !== 'OR') || !is_array($groupedDisplayConditions)) {
                     throw new \RuntimeException(
                         'Multiple conditions must have boolean operator "OR" or "AND", "' . $logicalOperator . '" given.',
index 1ec7121..e310030 100644 (file)
@@ -53,6 +53,28 @@ class EvaluateDisplayConditionsTest extends \TYPO3\TestingFramework\Core\Unit\Un
     /**
      * @test
      */
     /**
      * @test
      */
+    public function addDataThrowsExceptionIAConditionHasNoStringAsKey()
+    {
+        $input = [
+            'databaseRow' => [],
+            'processedTca' => [
+                'columns' => [
+                    'field_1' => [
+                        'displayCond' => [
+                            ['condition1'],
+                        ],
+                    ],
+                ],
+            ],
+        ];
+        $this->expectException(\RuntimeException::class);
+        $this->expectExceptionCode(1481380393);
+        (new EvaluateDisplayConditions())->addData($input);
+    }
+
+    /**
+     * @test
+     */
     public function addDataThrowsExceptionWithMultipleConditionsCombinedWithAndHavingOnlyOneSubCondition()
     {
         $input = [
     public function addDataThrowsExceptionWithMultipleConditionsCombinedWithAndHavingOnlyOneSubCondition()
     {
         $input = [