diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2024-01-15 13:50:44 -0100 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2024-01-15 15:45:13 -0100 |
commit | 6daea857ab286aae98120bf7d1e1034aeaa44bca (patch) | |
tree | e7edb14f82b87d04a032a287ab0339d0d29390d6 /core | |
parent | f7d0c74b1003af6c47dd6ec74f4ef904a2681d62 (diff) | |
download | nextcloud-server-6daea857ab286aae98120bf7d1e1034aeaa44bca.tar.gz nextcloud-server-6daea857ab286aae98120bf7d1e1034aeaa44bca.zip |
fixes
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
d
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/Command/Config/App/GetConfig.php | 17 | ||||
-rw-r--r-- | core/Command/Config/App/SetConfig.php | 41 | ||||
-rw-r--r-- | core/Migrations/Version29000Date20231126110901.php | 4 |
3 files changed, 24 insertions, 38 deletions
diff --git a/core/Command/Config/App/GetConfig.php b/core/Command/Config/App/GetConfig.php index 6052b88c013..f85f978cc61 100644 --- a/core/Command/Config/App/GetConfig.php +++ b/core/Command/Config/App/GetConfig.php @@ -83,20 +83,9 @@ class GetConfig extends Base { if ($input->getOption('details')) { $details = $this->appConfig->getDetails($appName, $configName); - $format = $input->getOption('output') ?? 'plain'; - if ($format === 'json') { - $output->writeln(json_encode($details)); - } elseif ($format === 'json_pretty') { - $output->writeln(json_encode($details, JSON_PRETTY_PRINT)); - } else { - $output->writeln('App: ' . $details['app'] ?? ''); - $output->writeln('Config Key: ' . $details['key'] ?? ''); - $output->writeln('Config Value: ' . $details['value'] ?? ''); - $output->writeln('Value type: ' . $details['typeString'] ?? ''); - $output->writeln('Lazy loaded: ' . (($details['lazy'] ?? false) ? 'Yes' : 'No')); - $output->writeln('Sensitive: ' . (($details['sensitive'] ?? false) ? 'Yes' : 'No')); - } - + $details['type'] = $details['typeString']; + unset($details['typeString']); + $this->writeArrayInOutputFormat($input, $output, $details); return 0; } diff --git a/core/Command/Config/App/SetConfig.php b/core/Command/Config/App/SetConfig.php index ac2c8fce6e9..35f2ba600a6 100644 --- a/core/Command/Config/App/SetConfig.php +++ b/core/Command/Config/App/SetConfig.php @@ -35,9 +35,6 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\Question; class SetConfig extends Base { - private InputInterface $input; - private OutputInterface $output; - public function __construct( protected IAppConfig $appConfig, ) { @@ -97,8 +94,6 @@ class SetConfig extends Base { protected function execute(InputInterface $input, OutputInterface $output): int { $appName = $input->getArgument('app'); $configName = $input->getArgument('name'); - $this->input = $input; - $this->output = $output; if (!($this->appConfig instanceof AppConfig)) { throw new \Exception('Only compatible with OC\AppConfig as it uses internal methods'); @@ -126,19 +121,19 @@ class SetConfig extends Base { */ $updated = false; if (!$input->hasParameterOption('--value')) { - if (!$input->getOption('lazy') && $this->appConfig->isLazy($appName, $configName) && $this->ask('NOT LAZY')) { + if (!$input->getOption('lazy') && $this->appConfig->isLazy($appName, $configName) && $this->ask($input, $output, 'NOT LAZY')) { $updated = $this->appConfig->updateLazy($appName, $configName, false); } - if ($input->getOption('lazy') && !$this->appConfig->isLazy($appName, $configName) && $this->ask('LAZY')) { + if ($input->getOption('lazy') && !$this->appConfig->isLazy($appName, $configName) && $this->ask($input, $output, 'LAZY')) { $updated = $this->appConfig->updateLazy($appName, $configName, true) || $updated; } - if (!$input->getOption('sensitive') && $this->appConfig->isSensitive($appName, $configName) && $this->ask('NOT SENSITIVE')) { + if (!$input->getOption('sensitive') && $this->appConfig->isSensitive($appName, $configName) && $this->ask($input, $output, 'NOT SENSITIVE')) { $updated = $this->appConfig->updateSensitive($appName, $configName, false) || $updated; } - if ($input->getOption('sensitive') && !$this->appConfig->isSensitive($appName, $configName) && $this->ask('SENSITIVE')) { + if ($input->getOption('sensitive') && !$this->appConfig->isSensitive($appName, $configName) && $this->ask($input, $output, 'SENSITIVE')) { $updated = $this->appConfig->updateSensitive($appName, $configName, true) || $updated; } - if ($typeString !== null && $type !== $this->appConfig->getValueType($appName, $configName) && $this->ask($typeString)) { + if ($type !== null && $type !== $this->appConfig->getValueType($appName, $configName) && $typeString !== null && $this->ask($input, $output, $typeString)) { $updated = $this->appConfig->updateType($appName, $configName, $type) || $updated; } } else { @@ -149,7 +144,7 @@ class SetConfig extends Base { */ try { $currType = $this->appConfig->getValueType($appName, $configName); - if ($type === null || $type === $currType || !$this->ask($typeString)) { + if ($typeString === null || $type === $currType || !$this->ask($input, $output, $typeString)) { $type = $currType; } else { $updated = $this->appConfig->updateType($appName, $configName, $type); @@ -166,7 +161,7 @@ class SetConfig extends Base { $lazy = $input->getOption('lazy'); try { $currLazy = $this->appConfig->isLazy($appName, $configName); - if ($lazy === null || $lazy === $currLazy || !$this->ask(($lazy) ? 'LAZY' : 'NOT LAZY')) { + if ($lazy === null || $lazy === $currLazy || !$this->ask($input, $output, ($lazy) ? 'LAZY' : 'NOT LAZY')) { $lazy = $currLazy; } } catch (AppConfigUnknownKeyException) { @@ -179,7 +174,7 @@ class SetConfig extends Base { $sensitive = $input->getOption('sensitive'); try { $currSensitive = $this->appConfig->isLazy($appName, $configName); - if ($sensitive === null || $sensitive === $currSensitive || !$this->ask(($sensitive) ? 'LAZY' : 'NOT LAZY')) { + if ($sensitive === null || $sensitive === $currSensitive || !$this->ask($input, $output, ($sensitive) ? 'LAZY' : 'NOT LAZY')) { $sensitive = $currSensitive; } } catch (AppConfigUnknownKeyException) { @@ -249,26 +244,26 @@ class SetConfig extends Base { return 0; } - private function ask(string $request): bool { + private function ask(InputInterface $input, OutputInterface $output, string $request): bool { $helper = $this->getHelper('question'); - if ($this->input->getOption('no-interaction')) { + if ($input->getOption('no-interaction')) { return true; } - $this->output->writeln(sprintf('You are about to set config value %s as <info>%s</info>', - '<info>' . $this->input->getArgument('app') . '</info>/<info>' . $this->input->getArgument('name') . '</info>', + $output->writeln(sprintf('You are about to set config value %s as <info>%s</info>', + '<info>' . $input->getArgument('app') . '</info>/<info>' . $input->getArgument('name') . '</info>', strtoupper($request) )); - $this->output->writeln(''); - $this->output->writeln('<comment>This might break thing, affect performance on your instance or its security!</comment>'); + $output->writeln(''); + $output->writeln('<comment>This might break thing, affect performance on your instance or its security!</comment>'); $result = (strtolower((string)$helper->ask( - $this->input, - $this->output, + $input, + $output, new Question('<comment>Confirm this action by typing \'yes\'</comment>: '))) === 'yes'); - $this->output->writeln(($result) ? 'done' : 'cancelled'); - $this->output->writeln(''); + $output->writeln(($result) ? 'done' : 'cancelled'); + $output->writeln(''); return $result; } diff --git a/core/Migrations/Version29000Date20231126110901.php b/core/Migrations/Version29000Date20231126110901.php index 6923c9bdbf7..3867074e013 100644 --- a/core/Migrations/Version29000Date20231126110901.php +++ b/core/Migrations/Version29000Date20231126110901.php @@ -31,7 +31,9 @@ use OCP\DB\Types; use OCP\Migration\IOutput; use OCP\Migration\SimpleMigrationStep; -// Create new field in appconfig for the new IAppConfig API, including lazy grouping. +/** + * Create new fields for type and lazy loading in appconfig for the new IAppConfig API. + */ class Version29000Date20231126110901 extends SimpleMigrationStep { public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { /** @var ISchemaWrapper $schema */ |