From 7b137ddd754f7dab5fcb8e0c34acb9b6d19b9a00 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Tue, 30 Nov 2021 16:45:51 +0100 Subject: feat(updater): hide overwrites from disabled apps list on upgrade If an incompatible app is enabled manually, it is added to the "app_install_overwrite" array in config.php. Nextcloud upgrades won't disable any app in this array, but they were still shown on the upgrade page and logs as being disabled. This commit assures that only apps which are really disabled, i.e. which are not in the "app_install_overwrite" array, are shown and logged as disabled during upgrades. Signed-off-by: MichaIng --- core/Command/Upgrade.php | 7 +++++-- core/ajax/update.php | 7 +++++-- lib/base.php | 8 +++++++- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/core/Command/Upgrade.php b/core/Command/Upgrade.php index c74b8d27049..45427f6552f 100644 --- a/core/Command/Upgrade.php +++ b/core/Command/Upgrade.php @@ -88,6 +88,7 @@ class Upgrade extends Command { $self = $this; $updater = \OCP\Server::get(Updater::class); + $incompatibleOverwrites = $this->config->getSystemValue('app_install_overwrite', []); /** @var IEventDispatcher $dispatcher */ $dispatcher = \OC::$server->get(IEventDispatcher::class); @@ -179,8 +180,10 @@ class Upgrade extends Command { $updater->listen('\OC\Updater', 'dbUpgrade', function () use ($output) { $output->writeln('Updated database'); }); - $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use ($output) { - $output->writeln('Disabled incompatible app: ' . $app . ''); + $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use ($output, &$incompatibleOverwrites) { + if (!in_array($app, $incompatibleOverwrites)) { + $output->writeln('Disabled incompatible app: ' . $app . ''); + } }); $updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($output) { $output->writeln('Update app ' . $app . ' from App Store'); diff --git a/core/ajax/update.php b/core/ajax/update.php index 63d1bd3cf5e..ed5fe00e147 100644 --- a/core/ajax/update.php +++ b/core/ajax/update.php @@ -120,6 +120,7 @@ if (\OCP\Util::needUpgrade()) { \OC::$server->query(\OC\Installer::class) ); $incompatibleApps = []; + $incompatibleOverwrites = $config->getSystemValue('app_install_overwrite', []); /** @var IEventDispatcher $dispatcher */ $dispatcher = \OC::$server->get(IEventDispatcher::class); @@ -162,8 +163,10 @@ if (\OCP\Util::needUpgrade()) { $updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($eventSource, $l) { $eventSource->send('success', $l->t('Updated "%1$s" to %2$s', [$app, $version])); }); - $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps) { - $incompatibleApps[] = $app; + $updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps, &$incompatibleOverwrites) { + if (!in_array($app, $incompatibleOverwrites)) { + $incompatibleApps[] = $app; + } }); $updater->listen('\OC\Updater', 'failure', function ($message) use ($eventSource, $config) { $eventSource->send('failure', $message); diff --git a/lib/base.php b/lib/base.php index e4fdb8efb44..72afa0753ba 100644 --- a/lib/base.php +++ b/lib/base.php @@ -35,6 +35,7 @@ declare(strict_types=1); * @author Lukas Reschke * @author MartB * @author Michael Gapczynski + * @author MichaIng * @author Morris Jobke * @author Owen Winkler * @author Phil Davis @@ -388,11 +389,16 @@ class OC { $ocVersion = \OCP\Util::getVersion(); $ocVersion = implode('.', $ocVersion); $incompatibleApps = $appManager->getIncompatibleApps($ocVersion); + $incompatibleOverwrites = $systemConfig->getValue('app_install_overwrite', []); $incompatibleShippedApps = []; + $incompatibleDisabledApps = []; foreach ($incompatibleApps as $appInfo) { if ($appManager->isShipped($appInfo['id'])) { $incompatibleShippedApps[] = $appInfo['name'] . ' (' . $appInfo['id'] . ')'; } + if (!in_array($appInfo['id'], $incompatibleOverwrites)) { + $incompatibleDisabledApps[] = $appInfo; + } } if (!empty($incompatibleShippedApps)) { @@ -402,7 +408,7 @@ class OC { } $tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion)); - $tmpl->assign('incompatibleAppsList', $incompatibleApps); + $tmpl->assign('incompatibleAppsList', $incompatibleDisabledApps); try { $defaults = new \OC_Defaults(); $tmpl->assign('productName', $defaults->getName()); -- cgit v1.2.3