From ac7128b8d34cdda493022878bd3665e3f13a35d9 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 17 Nov 2025 14:27:59 +0100 Subject: [PATCH] only check if config is writeable if a change is required --- utils/Commands/ConfigureextensionCommand.php | 24 +++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/utils/Commands/ConfigureextensionCommand.php b/utils/Commands/ConfigureextensionCommand.php index 6358d1554..61db46d3d 100644 --- a/utils/Commands/ConfigureextensionCommand.php +++ b/utils/Commands/ConfigureextensionCommand.php @@ -55,7 +55,7 @@ class ConfigureextensionCommand extends Command $output->writeln("Using configuration from '".$settings->_configFilePath."'.", OutputInterface::VERBOSITY_VERBOSE); - if (!is_writable($settings->_configFilePath)) { + if (($input->getOption('enable') || $input->getOption('disable')) && !is_writable($settings->_configFilePath)) { $output->writeln(sprintf("The configuration file '%s' is not writable by the system user running this script.", $settings->_configFilePath)); return Command::FAILURE; } @@ -69,23 +69,31 @@ class ConfigureextensionCommand extends Command if ($input->getOption('enable')) { if ($settings->extensionIsDisabled($extname)) { $settings->enableExtension($extname); + if (false === $settings->save()) { + $output->writeln(sprintf("Could not write configuration.", $extname)); + return Command::FAILURE; + } else { + $output->writeln(sprintf("Extension is %s.", $settings->extensionIsDisabled($extname) ? 'disabled' : 'enabled')); + } } else { - $output->writeln(sprintf("Extension already enabled.")); - return Command::SUCCESS; + $output->writeln(sprintf("Extension already enabled.")); } } elseif ($input->getOption('disable')) { if (!$settings->extensionIsDisabled($extname)) { $settings->disableExtension($extname); + if (false === $settings->save()) { + $output->writeln(sprintf("Could not write configuration.", $extname)); + return Command::FAILURE; + } else { + $output->writeln(sprintf("Extension is %s.", $settings->extensionIsDisabled($extname) ? 'disabled' : 'enabled')); + } } else { - $output->writeln(sprintf("Extension already disabled.")); - return Command::SUCCESS; + $output->writeln(sprintf("Extension already disabled.")); } } else { - $output->writeln(sprintf("Missing option --enable or --disable")); - return Command::FAILURE; + $output->writeln(sprintf("Extension is %s.", $settings->extensionIsDisabled($extname) ? 'disabled' : 'enabled')); } - $settings->save(); return Command::SUCCESS; } }