From d0bad0546357f16ba2e8dc7a450826d821fb51ff Mon Sep 17 00:00:00 2001 From: Andrey Borysenko Date: Thu, 26 Dec 2024 03:03:24 +0200 Subject: [PATCH 1/3] fix(occ): correct app_api:app:update enabled state of ExApps, introduce helper options Signed-off-by: Andrey Borysenko --- lib/Command/ExApp/Update.php | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/Command/ExApp/Update.php b/lib/Command/ExApp/Update.php index 7280d69b..d9156ec8 100644 --- a/lib/Command/ExApp/Update.php +++ b/lib/Command/ExApp/Update.php @@ -45,8 +45,10 @@ protected function configure(): void { $this->addOption('force-scopes', null, InputOption::VALUE_NONE, 'Force new ExApp scopes approval[deprecated]'); $this->addOption('wait-finish', null, InputOption::VALUE_NONE, 'Wait until finish'); $this->addOption('silent', null, InputOption::VALUE_NONE, 'Do not print to console'); - $this->addOption('all', null, InputOption::VALUE_NONE, 'Update all updatable apps'); + $this->addOption('all', null, InputOption::VALUE_NONE, 'Update all enabled and updatable apps'); $this->addOption('showonly', null, InputOption::VALUE_NONE, 'Additional flag for "--all" to only show all updatable apps'); + $this->addOption('include-disabled', null, InputOption::VALUE_NONE, 'Update also disabled apps (use --enable-after-update to enable ExApp after update)'); + $this->addOption('enable-after-update', null, InputOption::VALUE_NONE, 'Enable ExApp after update if it was disabled before. Use with --include-disabled'); } protected function execute(InputInterface $input, OutputInterface $output): int { @@ -105,6 +107,15 @@ private function updateExApp(InputInterface $input, OutputInterface $output, str return 1; } + $includeDisabledApps = $input->getOption('include-disabled'); + if ($input->getOption('all') && !$exApp->getEnabled() && !$includeDisabledApps) { + $this->logger->error(sprintf('ExApp %s is disabled. Update skipped (use --include-disabled to update disabled apps).', $appId)); + if ($outputConsole) { + $output->writeln(sprintf('ExApp %s is disabled. Update skipped (use --include-disabled to update disabled apps).', $appId)); + } + return 0; + } + $daemonConfig = $this->daemonConfigService->getDaemonConfigByName($exApp->getDaemonConfigName()); if ($daemonConfig === null) { $this->logger->error(sprintf('Daemon config %s not found.', $exApp->getDaemonConfigName())); @@ -140,7 +151,9 @@ private function updateExApp(InputInterface $input, OutputInterface $output, str $exApp->setStatus($status); $this->exAppService->updateExApp($exApp, ['status']); + $wasEnabled = false; if ($exApp->getEnabled()) { + $wasEnabled = true; if ($this->service->disableExApp($exApp)) { $this->logger->info(sprintf('ExApp %s successfully disabled.', $appId)); if ($outputConsole) { @@ -248,6 +261,20 @@ private function updateExApp(InputInterface $input, OutputInterface $output, str if ($outputConsole) { $output->writeln(sprintf('ExApp %s successfully updated.', $appId)); } + + if ($includeDisabledApps) { + $exApp = $this->exAppService->getExApp($appId); + $enableAfterUpdate = $input->getOption('enable-after-update'); + if (!$enableAfterUpdate && !$wasEnabled && $exApp->getEnabled()) { + if ($this->service->disableExApp($exApp)) { + $this->logger->info(sprintf('ExApp %s successfully disabled after update.', $appId)); + if ($outputConsole) { + $output->writeln(sprintf('ExApp %s successfully disabled after update.', $appId)); + } + } + } + } + return 0; } } From 10090ecf201ee8ceff5ac0c3590d760044b6022a Mon Sep 17 00:00:00 2001 From: Andrey Borysenko Date: Thu, 26 Dec 2024 22:48:03 +0200 Subject: [PATCH 2/3] fix(occ): remove redundant option, minor correction Signed-off-by: Andrey Borysenko --- lib/Command/ExApp/Update.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/Command/ExApp/Update.php b/lib/Command/ExApp/Update.php index d9156ec8..8eb0b10e 100644 --- a/lib/Command/ExApp/Update.php +++ b/lib/Command/ExApp/Update.php @@ -45,10 +45,9 @@ protected function configure(): void { $this->addOption('force-scopes', null, InputOption::VALUE_NONE, 'Force new ExApp scopes approval[deprecated]'); $this->addOption('wait-finish', null, InputOption::VALUE_NONE, 'Wait until finish'); $this->addOption('silent', null, InputOption::VALUE_NONE, 'Do not print to console'); - $this->addOption('all', null, InputOption::VALUE_NONE, 'Update all enabled and updatable apps'); + $this->addOption('all', null, InputOption::VALUE_NONE, 'Updates all enabled and updatable apps'); $this->addOption('showonly', null, InputOption::VALUE_NONE, 'Additional flag for "--all" to only show all updatable apps'); - $this->addOption('include-disabled', null, InputOption::VALUE_NONE, 'Update also disabled apps (use --enable-after-update to enable ExApp after update)'); - $this->addOption('enable-after-update', null, InputOption::VALUE_NONE, 'Enable ExApp after update if it was disabled before. Use with --include-disabled'); + $this->addOption('include-disabled', null, InputOption::VALUE_NONE, 'Additional flag for "--all" to also update disabled apps'); } protected function execute(InputInterface $input, OutputInterface $output): int { @@ -151,9 +150,8 @@ private function updateExApp(InputInterface $input, OutputInterface $output, str $exApp->setStatus($status); $this->exAppService->updateExApp($exApp, ['status']); - $wasEnabled = false; + $wasEnabled = $exApp->getEnabled(); if ($exApp->getEnabled()) { - $wasEnabled = true; if ($this->service->disableExApp($exApp)) { $this->logger->info(sprintf('ExApp %s successfully disabled.', $appId)); if ($outputConsole) { @@ -264,8 +262,7 @@ private function updateExApp(InputInterface $input, OutputInterface $output, str if ($includeDisabledApps) { $exApp = $this->exAppService->getExApp($appId); - $enableAfterUpdate = $input->getOption('enable-after-update'); - if (!$enableAfterUpdate && !$wasEnabled && $exApp->getEnabled()) { + if (!$wasEnabled && $exApp->getEnabled()) { if ($this->service->disableExApp($exApp)) { $this->logger->info(sprintf('ExApp %s successfully disabled after update.', $appId)); if ($outputConsole) { From 3e363f54b6e04f2fda5fbd287842da2ae9c916f5 Mon Sep 17 00:00:00 2001 From: Andrey Borysenko Date: Fri, 27 Dec 2024 15:16:07 +0200 Subject: [PATCH 3/3] fix(occ): minor correction Signed-off-by: Andrey Borysenko --- lib/Command/ExApp/Update.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Command/ExApp/Update.php b/lib/Command/ExApp/Update.php index 8eb0b10e..6fb464d1 100644 --- a/lib/Command/ExApp/Update.php +++ b/lib/Command/ExApp/Update.php @@ -108,7 +108,7 @@ private function updateExApp(InputInterface $input, OutputInterface $output, str $includeDisabledApps = $input->getOption('include-disabled'); if ($input->getOption('all') && !$exApp->getEnabled() && !$includeDisabledApps) { - $this->logger->error(sprintf('ExApp %s is disabled. Update skipped (use --include-disabled to update disabled apps).', $appId)); + $this->logger->info(sprintf('ExApp %s is disabled. Update skipped (use --include-disabled to update disabled apps).', $appId)); if ($outputConsole) { $output->writeln(sprintf('ExApp %s is disabled. Update skipped (use --include-disabled to update disabled apps).', $appId)); } @@ -151,7 +151,7 @@ private function updateExApp(InputInterface $input, OutputInterface $output, str $this->exAppService->updateExApp($exApp, ['status']); $wasEnabled = $exApp->getEnabled(); - if ($exApp->getEnabled()) { + if ($wasEnabled) { if ($this->service->disableExApp($exApp)) { $this->logger->info(sprintf('ExApp %s successfully disabled.', $appId)); if ($outputConsole) {