[BUGFIX] Wrong result on unequal globalVar condition 63/21663/3
authorMarc Bastian Heinrichs <typo3@mbh-software.de>
Wed, 26 Jun 2013 13:01:31 +0000 (15:01 +0200)
committerOliver Hader <oliver.hader@typo3.org>
Wed, 26 Jun 2013 14:23:53 +0000 (16:23 +0200)
A TypoScript condition like "[globalVar = LIT:10 != 10]"
returns a true value instead of the expected false value.
The reason for that is a superfluous trinity (type safe)
comparator.

Change-Id: Ib9f468da0a129f08d5d071a4f97bd09904f0c91b
Fixes: #45165
Releases: 6.0, 6.1, 6.2
Reviewed-on: https://review.typo3.org/21663
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
typo3/sysext/backend/Tests/Unit/Configuration/TypoScript/ConditionMatching/ConditionMatcherTest.php
typo3/sysext/core/Classes/Configuration/TypoScript/ConditionMatching/AbstractConditionMatcher.php
typo3/sysext/frontend/Tests/Unit/Configuration/TypoScript/ConditionMatching/ConditionMatcherTest.php

index e5ab629..bc39a14 100644 (file)
@@ -415,6 +415,15 @@ class ConditionMatcherTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        }
 
        /**
+        * Tests whether numerical comparison does not match.
+        *
+        * @test
+        */
+       public function globalVarConditionDoesNotMatchOnNotEqualExpression() {
+               $this->assertFalse($this->matchCondition->match('[globalVar = LIT:10 != 10]'));
+       }
+
+       /**
         * Tests whether numerical comparison matches.
         *
         * @test
index 05861b0..82f37c9 100644 (file)
@@ -481,7 +481,7 @@ abstract class AbstractConditionMatcher {
                                $found = FALSE;
                                $rightValueParts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('|', $rightValue);
                                foreach ($rightValueParts as $rightValueSingle) {
-                                       if ($leftValue === doubleval($rightValueSingle)) {
+                                       if ($leftValue == doubleval($rightValueSingle)) {
                                                $found = TRUE;
                                                break;
                                        }
@@ -666,4 +666,4 @@ abstract class AbstractConditionMatcher {
 }
 
 
-?>
\ No newline at end of file
+?>
index 3ec7cf3..69e8dc4 100644 (file)
@@ -370,6 +370,15 @@ class ConditionMatcherTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        }
 
        /**
+        * Tests whether numerical comparison does not match.
+        *
+        * @test
+        */
+       public function globalVarConditionDoesNotMatchOnNotEqualExpression() {
+               $this->assertFalse($this->matchCondition->match('[globalVar = LIT:10 != 10]'));
+       }
+
+       /**
         * Tests whether numerical comparison matches.
         *
         * @test