[BUGFIX] Properly check TS conditions with key '0' 50/35950/2
authorChristian Futterlieb <christian@futterlieb.ch>
Thu, 8 Jan 2015 18:21:09 +0000 (19:21 +0100)
committerMarkus Klein <klein.t3@reelworx.at>
Sat, 10 Jan 2015 21:52:18 +0000 (22:52 +0100)
Global vars and strings from array expressions with key '0' must be
checked correctly in TS conditions.
E.g. when using [globalVar = GP:myoption|0 = 1] the 0 is now
correctly evaluated.

Resolves: #64192
Releases: master, 6.2
Change-Id: I1100042670ffd458dfb81e6a6eac126dbc01a531
Reviewed-on: http://review.typo3.org/35950
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/core/Classes/Configuration/TypoScript/ConditionMatching/AbstractConditionMatcher.php
typo3/sysext/frontend/Tests/Unit/Configuration/TypoScript/ConditionMatching/ConditionMatcherTest.php

index 1b9f2ea..83d249e 100644 (file)
@@ -484,7 +484,7 @@ abstract class AbstractConditionMatcher {
                                }
                                // If array:
                                if (count($splitAgain) > 1) {
-                                       if (is_array($value) && trim($splitAgain[1])) {
+                                       if (is_array($value) && trim($splitAgain[1]) !== '') {
                                                $value = $this->getGlobal($splitAgain[1], $value);
                                        } else {
                                                $value = '';
index 423a2fe..352719c 100644 (file)
@@ -442,6 +442,19 @@ class ConditionMatcherTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        }
 
        /**
+        * Tests whether an array with zero as key matches its value
+        *
+        * @test
+        */
+       public function globalVarConditionMatchesOnArrayExpressionWithZeroAsKey() {
+               $testKey = uniqid('test');
+               $testValue = '1';
+               $_GET = array();
+               $_POST = array($testKey => array('0' => $testValue));
+               $this->assertTrue($this->matchCondition->match('[globalVar = GP:' . $testKey . '|0=' . $testValue . ']'));
+       }
+
+       /**
         * Tests whether string comparison matches.
         *
         * @test