[TASK] Add language debug mode to All Configuration 56/51856/4
authorThomas Hohn <thomas@hohn.dk>
Sat, 25 Feb 2017 14:30:45 +0000 (15:30 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 1 Mar 2017 10:55:51 +0000 (11:55 +0100)
Renamed $TYPO3_CONF_VARS['BE']['lang']['debug'] to
$TYPO3_CONF_VARS['BE']['languageDebug'] in order to
be able to set value in install-tool.

Resolves: #71095
Releases: master
Change-Id: I49cf8516db5d535a8fe2cac6330ce2ebc3aba783
Reviewed-on: https://review.typo3.org/51856
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Configuration/DefaultConfiguration.php
typo3/sysext/core/Configuration/DefaultConfigurationDescription.php
typo3/sysext/core/Documentation/Changelog/master/Important-71095-AddLanguageDebugModeToAllConfiguration.rst [new file with mode: 0644]
typo3/sysext/install/Classes/Service/SilentConfigurationUpgradeService.php
typo3/sysext/install/Tests/Unit/Service/SilentConfigurationUpgradeServiceTest.php
typo3/sysext/lang/Classes/LanguageService.php

index fa91687..94eeeac 100644 (file)
@@ -762,9 +762,7 @@ return [
     ],
     'BE' => [
         // Backend Configuration.
-        'lang' => [
-            'debug' => false
-        ],
+        'languageDebug' => false,
         'fileadminDir' => 'fileadmin/',
         'RTE_imageStorageDir' => 'uploads/',
         'lockRootPath' => '',
index 4b4b4e2..e87097b 100644 (file)
@@ -94,6 +94,7 @@ return [
         'excludeForPackaging' => 'String: List of directories and files which will not be packaged into extensions nor taken into account otherwise by the Extension Manager. Perl regular expression syntax!',
     ],
     'BE' => [ // Backend Configuration.
+        'languageDebug' => 'Boolean: If set languageDebug will be enabled in LanguageService',
         'fileadminDir' => 'Path to the fileadmin dir. This is relative to PATH_site, DefaultStorage will be created with that configuration, do not access manually but ResourceFactory::getDefaultStorage()',
         'RTE_imageStorageDir' => 'Default storage directory for Rich Text Editor files',
         'lockRootPath' => 'This path is used to evaluate if paths outside of PATH_site should be allowed. Ending slash required!',
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Important-71095-AddLanguageDebugModeToAllConfiguration.rst b/typo3/sysext/core/Documentation/Changelog/master/Important-71095-AddLanguageDebugModeToAllConfiguration.rst
new file mode 100644 (file)
index 0000000..616bf54
--- /dev/null
@@ -0,0 +1,19 @@
+.. include:: ../../Includes.txt
+
+================================================================
+Important: #71095 - Add language debug mode to All Configuration
+================================================================
+
+See :issue:`71095`
+
+Description
+===========
+
+Previously it was possible to set: $TYPO3_CONF_VARS['BE']['lang']['debug']
+in order to enable debug in LanguageService.
+
+However this could not be configured in the install tool.
+In order to enable this possibility it has been renamed to
+$TYPO3_CONF_VARS['BE']['languageDebug']
+
+.. index:: Backend
\ No newline at end of file
index 20591fd..d73bcbd 100644 (file)
@@ -89,7 +89,9 @@ class SilentConfigurationUpgradeService
         'FE/lockHashKeyWords',
         'BE/lockHashKeyWords',
         // #78835
-        'SYS/cookieHttpOnly'
+        'SYS/cookieHttpOnly',
+        // #71095
+        'BE/lang'
     ];
 
     public function __construct(ConfigurationManager $configurationManager = null)
@@ -111,12 +113,15 @@ class SilentConfigurationUpgradeService
         $this->transferHttpSettings();
         $this->disableImageMagickDetailSettingsIfImageMagickIsDisabled();
         $this->setImageMagickDetailSettings();
-        $this->removeObsoleteLocalConfigurationSettings();
         $this->migrateThumbnailsPngSetting();
         $this->migrateLockSslSetting();
         $this->migrateDatabaseConnectionSettings();
         $this->migrateDatabaseConnectionCharset();
         $this->migrateDatabaseDriverOptions();
+        $this->migrateLangDebug();
+
+        // Should run at the end to prevent that obsolete settings are removed before migration
+        $this->removeObsoleteLocalConfigurationSettings();
     }
 
     /**
@@ -734,4 +739,23 @@ class SilentConfigurationUpgradeService
             // no driver options found, nothing needs to be modified
         }
     }
+
+    /**
+     * Migrate the configuration setting BE/lang/debug if set in the LocalConfiguration.php file
+     *
+     * @return void
+     */
+    protected function migrateLangDebug()
+    {
+        $confManager = $this->configurationManager;
+        try {
+            $currentOption = $confManager->getLocalConfigurationValueByPath('BE/lang/debug');
+            // check if the current option is set and boolean
+            if (isset($currentOption) && is_bool($currentOption)) {
+                $confManager->setLocalConfigurationValueByPath('BE/languageDebug', $currentOption);
+            }
+        } catch (\RuntimeException $e) {
+            // no change inside the LocalConfiguration.php found, so nothing needs to be modified
+        }
+    }
 }
index 5050dfd..2ff9168 100644 (file)
@@ -598,4 +598,74 @@ class SilentConfigurationUpgradeServiceTest extends \TYPO3\TestingFramework\Core
 
         $silentConfigurationUpgradeServiceInstance->_call('setImageMagickDetailSettings');
     }
+
+    /**
+     * @test
+     */
+    public function migrateNonExistingLangDebug()
+    {
+        /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
+        $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
+            SilentConfigurationUpgradeService::class,
+            ['dummy'],
+            [],
+            '',
+            false
+        );
+
+        $currentLocalConfiguration = [
+        ];
+        $this->createConfigurationManagerWithMockedMethods(
+            [
+                'getLocalConfigurationValueByPath',
+                'setLocalConfigurationValueByPath',
+            ]
+        );
+
+        $this->configurationManager->expects($this->exactly(1))
+            ->method('getLocalConfigurationValueByPath')
+            ->will($this->returnValueMap($currentLocalConfiguration));
+        $this->configurationManager->expects($this->never())
+            ->method('setLocalConfigurationValueByPath');
+
+        $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
+
+        $silentConfigurationUpgradeServiceInstance->_call('migrateLangDebug');
+    }
+
+    /**
+     * @test
+     */
+    public function migrateExistingLangDebug()
+    {
+        /** @var $silentConfigurationUpgradeServiceInstance SilentConfigurationUpgradeService|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
+        $silentConfigurationUpgradeServiceInstance = $this->getAccessibleMock(
+            SilentConfigurationUpgradeService::class,
+            ['dummy'],
+            [],
+            '',
+            false
+        );
+
+        $currentLocalConfiguration = [
+            ['BE/lang/debug', false]
+        ];
+        $this->createConfigurationManagerWithMockedMethods(
+            [
+                'getLocalConfigurationValueByPath',
+                'setLocalConfigurationValueByPath',
+            ]
+        );
+
+        $this->configurationManager->expects($this->exactly(1))
+            ->method('getLocalConfigurationValueByPath')
+            ->will($this->returnValueMap($currentLocalConfiguration));
+        $this->configurationManager->expects($this->once())
+            ->method('setLocalConfigurationValueByPath')
+            ->with($this->equalTo('BE/languageDebug'), false);
+
+        $silentConfigurationUpgradeServiceInstance->_set('configurationManager', $this->configurationManager);
+
+        $silentConfigurationUpgradeServiceInstance->_call('migrateLangDebug');
+    }
 }
index 848e1dc..13b0002 100644 (file)
@@ -109,7 +109,7 @@ class LanguageService
         $this->csConvObj = GeneralUtility::makeInstance(CharsetConverter::class);
         // Initialize the localization factory object
         $this->parserFactory = GeneralUtility::makeInstance(LocalizationFactory::class);
-        if ($GLOBALS['TYPO3_CONF_VARS']['BE']['lang']['debug']) {
+        if ($GLOBALS['TYPO3_CONF_VARS']['BE']['languageDebug']) {
             $this->debugKey = true;
         }
     }