Skip to content

Commit

Permalink
[stable30] fix(occ): correct app_api:app:update enabled state of ExAp…
Browse files Browse the repository at this point in the history
…ps, introduce helper options (#479)

Manual backport of: #478

---------

Signed-off-by: Andrey Borysenko <[email protected]>
  • Loading branch information
andrey18106 authored Dec 27, 2024
1 parent f105a1e commit f16cbd8
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions lib/Command/ExApp/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +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 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, 'Additional flag for "--all" to also update disabled apps');
}

protected function execute(InputInterface $input, OutputInterface $output): int {
Expand Down Expand Up @@ -105,6 +106,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->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));
}
return 0;
}

$daemonConfig = $this->daemonConfigService->getDaemonConfigByName($exApp->getDaemonConfigName());
if ($daemonConfig === null) {
$this->logger->error(sprintf('Daemon config %s not found.', $exApp->getDaemonConfigName()));
Expand Down Expand Up @@ -140,7 +150,8 @@ private function updateExApp(InputInterface $input, OutputInterface $output, str
$exApp->setStatus($status);
$this->exAppService->updateExApp($exApp, ['status']);

if ($exApp->getEnabled()) {
$wasEnabled = $exApp->getEnabled();
if ($wasEnabled) {
if ($this->service->disableExApp($exApp)) {
$this->logger->info(sprintf('ExApp %s successfully disabled.', $appId));
if ($outputConsole) {
Expand Down Expand Up @@ -248,6 +259,19 @@ 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);
if (!$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;
}
}

0 comments on commit f16cbd8

Please sign in to comment.