From c92ef6920cd2dbd7bfd5f0faad0cb2ea2c36f343 Mon Sep 17 00:00:00 2001 From: Claus Due <claus@namelesscoder.net> Date: Mon, 16 Dec 2019 12:01:11 +0100 Subject: [PATCH] [TASK] Remove dead code in ExtensionConfiguration class This patch: * Removes dead code which deals with setting an extension configuration option by path (which is not supported!) * Removes an unused parameter to pass the path. * Adjusts tests and usages of the class to no longer pass an empty string as $path argument. Releases: master Resolves: #89957 Change-Id: Ia74a9d9994056599006e375ec63c32dcd8e4c403 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62650 Tested-by: Oliver Bartsch <bo@cedev.de> Tested-by: TYPO3com <noreply@typo3.com> Tested-by: Daniel Goerz <daniel.goerz@posteo.de> Reviewed-by: Oliver Bartsch <bo@cedev.de> Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de> Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de> --- .../Classes/Configuration/ExtensionConfiguration.php | 10 ++-------- .../Unit/Configuration/ExtensionConfigurationTest.php | 2 +- .../install/Classes/Controller/SettingsController.php | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/typo3/sysext/core/Classes/Configuration/ExtensionConfiguration.php b/typo3/sysext/core/Classes/Configuration/ExtensionConfiguration.php index 515bf89c9da0..340d2fc4d8d2 100644 --- a/typo3/sysext/core/Classes/Configuration/ExtensionConfiguration.php +++ b/typo3/sysext/core/Classes/Configuration/ExtensionConfiguration.php @@ -142,20 +142,14 @@ class ExtensionConfiguration * ->set() call and values may not end up as expected. * * @param string $extension Extension name - * @param string $path Configuration path to set - eg. "featureCategory/coolThingIsEnabled" * @param mixed|null $value The value. If null, unset the path * @internal */ - public function set(string $extension, string $path = '', $value = null): void + public function set(string $extension, $value = null): void { if (empty($extension)) { throw new \RuntimeException('extension name must not be empty', 1509715852); } - if (!empty($path)) { - // @todo: this functionality can be removed once EXT:bootstrap_package is adapted to the new API. - $extensionConfiguration = $this->get($extension); - $value = ArrayUtility::setValueByPath($extensionConfiguration, $path, $value); - } $configurationManager = GeneralUtility::makeInstance(ConfigurationManager::class); if ($value === null) { // Remove whole extension config @@ -237,7 +231,7 @@ class ExtensionConfiguration ArrayUtility::mergeRecursiveWithOverrule($extConfTemplateConfiguration, $currentLocalConfiguration); // Write new config if changed. Loose array comparison to not write if only array key order is different if ($extConfTemplateConfiguration != $currentLocalConfiguration) { - $this->set($extensionKey, '', $extConfTemplateConfiguration); + $this->set($extensionKey, $extConfTemplateConfiguration); } } diff --git a/typo3/sysext/core/Tests/Unit/Configuration/ExtensionConfigurationTest.php b/typo3/sysext/core/Tests/Unit/Configuration/ExtensionConfigurationTest.php index d8e1a58cec4a..3ca1cf9874f9 100644 --- a/typo3/sysext/core/Tests/Unit/Configuration/ExtensionConfigurationTest.php +++ b/typo3/sysext/core/Tests/Unit/Configuration/ExtensionConfigurationTest.php @@ -101,6 +101,6 @@ class ExtensionConfigurationTest extends UnitTestCase GeneralUtility::addInstance(ConfigurationManager::class, $configurationManagerProphecy->reveal()); $configurationManagerProphecy->setLocalConfigurationValueByPath(Argument::cetera())->shouldBeCalled(); $configurationManagerProphecy->setLocalConfigurationValueByPath('EXTENSIONS/foo', ['bar' => 'baz'])->shouldBeCalled(); - (new ExtensionConfiguration())->set('foo', '', ['bar' => 'baz']); + (new ExtensionConfiguration())->set('foo', ['bar' => 'baz']); } } diff --git a/typo3/sysext/install/Classes/Controller/SettingsController.php b/typo3/sysext/install/Classes/Controller/SettingsController.php index be44efff8e06..8328d30616ac 100644 --- a/typo3/sysext/install/Classes/Controller/SettingsController.php +++ b/typo3/sysext/install/Classes/Controller/SettingsController.php @@ -447,7 +447,7 @@ class SettingsController extends AbstractController foreach ($configuration as $configKey => $value) { $nestedConfiguration = ArrayUtility::setValueByPath($nestedConfiguration, $configKey, $value, '.'); } - (new ExtensionConfiguration())->set($extensionKey, '', $nestedConfiguration); + (new ExtensionConfiguration())->set($extensionKey, $nestedConfiguration); $messages = [ new FlashMessage( 'Successfully saved configuration for extension "' . $extensionKey . '".', -- GitLab