only check if config is writeable if a change is required

This commit is contained in:
Uwe Steinmann 2025-11-17 14:27:59 +01:00
parent 32351d6179
commit ac7128b8d3

View File

@ -55,7 +55,7 @@ class ConfigureextensionCommand extends Command
$output->writeln("<comment>Using configuration from '".$settings->_configFilePath."'.</comment>", OutputInterface::VERBOSITY_VERBOSE); $output->writeln("<comment>Using configuration from '".$settings->_configFilePath."'.</comment>", OutputInterface::VERBOSITY_VERBOSE);
if (!is_writable($settings->_configFilePath)) { if (($input->getOption('enable') || $input->getOption('disable')) && !is_writable($settings->_configFilePath)) {
$output->writeln(sprintf("<error>The configuration file '%s' is not writable by the system user running this script.</error>", $settings->_configFilePath)); $output->writeln(sprintf("<error>The configuration file '%s' is not writable by the system user running this script.</error>", $settings->_configFilePath));
return Command::FAILURE; return Command::FAILURE;
} }
@ -69,23 +69,31 @@ class ConfigureextensionCommand extends Command
if ($input->getOption('enable')) { if ($input->getOption('enable')) {
if ($settings->extensionIsDisabled($extname)) { if ($settings->extensionIsDisabled($extname)) {
$settings->enableExtension($extname); $settings->enableExtension($extname);
if (false === $settings->save()) {
$output->writeln(sprintf("<error>Could not write configuration.</error>", $extname));
return Command::FAILURE;
} else {
$output->writeln(sprintf("Extension is %s.", $settings->extensionIsDisabled($extname) ? 'disabled' : 'enabled'));
}
} else { } else {
$output->writeln(sprintf("<info>Extension already enabled.</info>")); $output->writeln(sprintf("Extension already enabled."));
return Command::SUCCESS;
} }
} elseif ($input->getOption('disable')) { } elseif ($input->getOption('disable')) {
if (!$settings->extensionIsDisabled($extname)) { if (!$settings->extensionIsDisabled($extname)) {
$settings->disableExtension($extname); $settings->disableExtension($extname);
if (false === $settings->save()) {
$output->writeln(sprintf("<error>Could not write configuration.</error>", $extname));
return Command::FAILURE;
} else {
$output->writeln(sprintf("Extension is %s.", $settings->extensionIsDisabled($extname) ? 'disabled' : 'enabled'));
}
} else { } else {
$output->writeln(sprintf("<info>Extension already disabled.</info>")); $output->writeln(sprintf("Extension already disabled."));
return Command::SUCCESS;
} }
} else { } else {
$output->writeln(sprintf("<error>Missing option --enable or --disable</error>")); $output->writeln(sprintf("Extension is %s.", $settings->extensionIsDisabled($extname) ? 'disabled' : 'enabled'));
return Command::FAILURE;
} }
$settings->save();
return Command::SUCCESS; return Command::SUCCESS;
} }
} }