[BUGFIX] Use REDIRECT_ prefix as fallback for environment variables 23/25123/10
authorSteffen Müller <typo3@t3node.com>
Wed, 30 Apr 2014 11:21:39 +0000 (13:21 +0200)
committerSteffen Müller <typo3@t3node.com>
Wed, 30 Apr 2014 16:38:40 +0000 (18:38 +0200)
The core uses values of environment variables for
disabling the core updater and to determine the
application context.

When setting the variable with mod_rewrite, certain server environments
prefix the variable name with REDIRECT_.
To ensure compatibility for this case, REDIRECT_
prefix is prepended as a fallback if the regular
variable is not set.

Resolves: #53188
Resolves: #58358
Resolves: #53974
Releases: 6.2
Change-Id: Iaba7f936ff1362d1f70426ec8ad1b1821e4e0d3c
Reviewed-on: https://review.typo3.org/25123
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Steffen Müller
Tested-by: Steffen Müller
typo3/sysext/core/Classes/Core/Bootstrap.php
typo3/sysext/install/Classes/Service/CoreUpdateService.php
typo3/sysext/install/Tests/Unit/Service/CoreUpdateServiceTest.php

index 729bbb7..a907831 100644 (file)
@@ -103,7 +103,7 @@ class Bootstrap {
                if (is_null(static::$instance)) {
                        require_once(__DIR__ . '/../Exception.php');
                        require_once(__DIR__ . '/ApplicationContext.php');
-                       $applicationContext = trim(getenv('TYPO3_CONTEXT'), '"\' ') ? : 'Production';
+                       $applicationContext = getenv('TYPO3_CONTEXT') ?: (getenv('REDIRECT_TYPO3_CONTEXT') ?: 'Production');
                        self::$instance = new static($applicationContext);
                        // Establish an alias for Flow/Package interoperability
                        class_alias(get_class(static::$instance), 'TYPO3\\Flow\\Core\\Bootstrap');
index e22dd75..3f8dbd2 100644 (file)
@@ -94,7 +94,8 @@ class CoreUpdateService {
         * @return boolean
         */
        public function isCoreUpdateEnabled() {
-               return (getenv('TYPO3_DISABLE_CORE_UPDATER') !== '1');
+               $coreUpdateDisabled = getenv('TYPO3_DISABLE_CORE_UPDATER') ?: (getenv('REDIRECT_TYPO3_DISABLE_CORE_UPDATER') ?: FALSE);
+               return !$coreUpdateDisabled;
        }
 
        /**
index 9f0e77b..5af76e2 100644 (file)
@@ -42,4 +42,37 @@ class CoreUpdateServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                $instance->_set('messages', $aMessage);
                $this->assertSame($aMessage, $instance->getMessages());
        }
+
+       /**
+        * @test
+        */
+       public function isCoreUpdateEnabledReturnsTrueForEnvironmentVariableNotSet() {
+               /** @var $instance \TYPO3\CMS\Install\Service\CoreUpdateService|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
+               $instance = $this->getAccessibleMock('TYPO3\\CMS\\Install\\Service\\CoreUpdateService', array('dummy'), array(), '', FALSE);
+               putenv('TYPO3_DISABLE_CORE_UPDATER');
+               putenv('REDIRECT_TYPO3_DISABLE_CORE_UPDATER');
+               $this->assertTrue($instance->isCoreUpdateEnabled());
+       }
+
+       /**
+        * @test
+        */
+       public function isCoreUpdateEnabledReturnsFalseFor_TYPO3_DISABLE_CORE_UPDATER_EnvironmentVariableSet() {
+               /** @var $instance \TYPO3\CMS\Install\Service\CoreUpdateService|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
+               $instance = $this->getAccessibleMock('TYPO3\\CMS\\Install\\Service\\CoreUpdateService', array('dummy'), array(), '', FALSE);
+               putenv('TYPO3_DISABLE_CORE_UPDATER=1');
+               putenv('REDIRECT_TYPO3_DISABLE_CORE_UPDATER');
+               $this->assertFalse($instance->isCoreUpdateEnabled());
+       }
+
+       /**
+        * @test
+        */
+       public function isCoreUpdateEnabledReturnsFalseFor_REDIRECT_TYPO3_DISABLE_CORE_UPDATER_EnvironmentVariableSet() {
+               /** @var $instance \TYPO3\CMS\Install\Service\CoreUpdateService|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject */
+               $instance = $this->getAccessibleMock('TYPO3\\CMS\\Install\\Service\\CoreUpdateService', array('dummy'), array(), '', FALSE);
+               putenv('TYPO3_DISABLE_CORE_UPDATER');
+               putenv('REDIRECT_TYPO3_DISABLE_CORE_UPDATER=1');
+               $this->assertFalse($instance->isCoreUpdateEnabled());
+       }
 }
\ No newline at end of file