From 5f9897575102a63501d6909f3ac5a11a19969a3d Mon Sep 17 00:00:00 2001 From: Alex Gusev Date: Wed, 16 Sep 2020 18:59:52 +0300 Subject: [PATCH 1/4] Prevent "Overwrite the existing configuration for ...?" question Duplication for PR https://github.com/magento/magento2/pull/26818 --- .../src/Magento/Setup/Console/Command/ConfigSetCommand.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php b/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php index e8ff8f09c345e..bd0fb90298823 100644 --- a/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php +++ b/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php @@ -84,7 +84,11 @@ protected function execute(InputInterface $input, OutputInterface $output) $commandOptions[$option->getName()] = false; $currentValue = $this->deploymentConfig->get($option->getConfigPath()); - if (($currentValue !== null) && ($inputOptions[$option->getName()] !== null)) { + if ( + ($currentValue !== null) && + ($inputOptions[$option->getName()] !== null) && + ($inputOptions[$option->getName()] !== $currentValue) + ) { $dialog = $this->getHelperSet()->get('question'); $question = new Question( 'Overwrite the existing configuration for ' . $option->getName() . '?[Y/n]', From cf1a716e7a40acc30e763b0b68ca2e6f9ba85cac Mon Sep 17 00:00:00 2001 From: Alex Gusev Date: Thu, 17 Sep 2020 09:12:20 +0300 Subject: [PATCH 2/4] Update ConfigSetCommand.php fix static tests failures: ``` /var/www/html/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php:76 The method execute() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. ``` ``` FILE: ...tml/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php ---------------------------------------------------------------------- FOUND 0 ERRORS AND 2 WARNINGS AFFECTING 2 LINES ---------------------------------------------------------------------- 20 | WARNING | [ ] Class description should contain additional | | information beyond the name already supplies. 87 | WARNING | [x] Expected 0 spaces after opening bracket; newline | | found ---------------------------------------------------------------------- PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY ---------------------------------------------------------------------- ``` --- .../src/Magento/Setup/Console/Command/ConfigSetCommand.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php b/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php index bd0fb90298823..ed9e4f02f748e 100644 --- a/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php +++ b/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php @@ -84,11 +84,10 @@ protected function execute(InputInterface $input, OutputInterface $output) $commandOptions[$option->getName()] = false; $currentValue = $this->deploymentConfig->get($option->getConfigPath()); - if ( - ($currentValue !== null) && + $needOverwrite = ($currentValue !== null) && ($inputOptions[$option->getName()] !== null) && - ($inputOptions[$option->getName()] !== $currentValue) - ) { + ($inputOptions[$option->getName()] !== $currentValue); + if ($needOverwrite) { $dialog = $this->getHelperSet()->get('question'); $question = new Question( 'Overwrite the existing configuration for ' . $option->getName() . '?[Y/n]', From 5c23f4d24d6ff9c95f50ba3378498676ba548eb4 Mon Sep 17 00:00:00 2001 From: Ihor Sviziev Date: Thu, 17 Sep 2020 09:36:41 +0300 Subject: [PATCH 3/4] Fix static test --- setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php b/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php index ed9e4f02f748e..5fb43570ebfb2 100644 --- a/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php +++ b/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php @@ -14,9 +14,6 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\Question; -/** - * Config Set Command - */ class ConfigSetCommand extends AbstractSetupCommand { /** From 23aa8067a9d5a5d99a7851d63bf5eb486508f168 Mon Sep 17 00:00:00 2001 From: Ihor Sviziev Date: Thu, 17 Sep 2020 15:09:09 +0300 Subject: [PATCH 4/4] Fix static test --- setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php | 1 + 1 file changed, 1 insertion(+) diff --git a/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php b/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php index 5fb43570ebfb2..9380a7b72d6b2 100644 --- a/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php +++ b/setup/src/Magento/Setup/Console/Command/ConfigSetCommand.php @@ -69,6 +69,7 @@ protected function configure() /** * @inheritdoc + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ protected function execute(InputInterface $input, OutputInterface $output) {