[BUGFIX] Use runtime cache for getIndpEnv() for results which are NULL 05/58005/4
authorMichael Stucki <michael.stucki@typo3.org>
Thu, 23 Aug 2018 13:43:49 +0000 (15:43 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 2 Sep 2018 12:54:19 +0000 (14:54 +0200)
isset() returns FALSE if a cached result is NULL.
Use array_key_exists() instead.

Resolves: #85946
Related: #69173
Releases: master, 8.7
Change-Id: I32bf695f7778213bacc51ed569250466685f1dac
Reviewed-on: https://review.typo3.org/58005
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Tests/Unit/Configuration/TypoScript/ConditionMatching/ConditionMatcherTest.php
typo3/sysext/core/Classes/Utility/GeneralUtility.php
typo3/sysext/frontend/Tests/Unit/Configuration/TypoScript/ConditionMatching/ConditionMatcherTest.php

index cb17774..c1810db 100644 (file)
@@ -915,6 +915,8 @@ class ConditionMatcherTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCas
     public function genericGetVariablesSucceedsWithNamespaceIENV()
     {
         $_SERVER['HTTP_HOST'] = GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY') . ':1234567';
+        // getIndpEnv() is polluted after above call, clear cache to have it recalculate for subject execption
+        GeneralUtility::flushInternalRuntimeCaches();
         $this->assertTrue($this->matchCondition->match('[globalString = IENV:TYPO3_PORT = 1234567]'));
         // Test expression language
         // Access to global variables is not possible in expression language
index 186f419..d5763e8 100644 (file)
@@ -2646,7 +2646,7 @@ class GeneralUtility
      */
     public static function getIndpEnv($getEnvName)
     {
-        if (isset(self::$indpEnvCache[$getEnvName])) {
+        if (array_key_exists($getEnvName, self::$indpEnvCache)) {
             return self::$indpEnvCache[$getEnvName];
         }
 
index f179478..5327d26 100644 (file)
@@ -847,6 +847,8 @@ class ConditionMatcherTest extends UnitTestCase
     public function genericGetVariablesSucceedsWithNamespaceIENV(): void
     {
         $_SERVER['HTTP_HOST'] = GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY') . ':1234567';
+        // getIndpEnv() is polluted after above call, clear cache to have it recalculate for subject execption
+        GeneralUtility::flushInternalRuntimeCaches();
         $this->getFreshConditionMatcher();
         $this->assertTrue($this->subject->match('[globalString = IENV:TYPO3_PORT = 1234567]'));
         // Test expression language