Skip to content

Commit ab6c32e

Browse files
committed
enh(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 <micha@dietpi.com>
1 parent 455a209 commit ab6c32e

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

core/Command/Upgrade.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8888

8989
$self = $this;
9090
$updater = \OCP\Server::get(Updater::class);
91+
$incompatibleOverwrites = $this->config->getSystemValue('app_install_overwrite', []);
9192

9293
/** @var IEventDispatcher $dispatcher */
9394
$dispatcher = \OC::$server->get(IEventDispatcher::class);
@@ -179,8 +180,10 @@ function ($success) use ($output, $self) {
179180
$updater->listen('\OC\Updater', 'dbUpgrade', function () use ($output) {
180181
$output->writeln('<info>Updated database</info>');
181182
});
182-
$updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use ($output) {
183-
$output->writeln('<comment>Disabled incompatible app: ' . $app . '</comment>');
183+
$updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use ($output, &$incompatibleOverwrites) {
184+
if (!in_array($app, $incompatibleOverwrites)) {
185+
$output->writeln('<comment>Disabled incompatible app: ' . $app . '</comment>');
186+
}
184187
});
185188
$updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($output) {
186189
$output->writeln('<info>Update app ' . $app . ' from App Store</info>');

core/ajax/update.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ public function handleRepairFeedback(Event $event): void {
120120
\OC::$server->query(\OC\Installer::class)
121121
);
122122
$incompatibleApps = [];
123+
$incompatibleOverwrites = $config->getSystemValue('app_install_overwrite', []);
123124

124125
/** @var IEventDispatcher $dispatcher */
125126
$dispatcher = \OC::$server->get(IEventDispatcher::class);
@@ -162,8 +163,10 @@ function (MigratorExecuteSqlEvent $event) use ($eventSource, $l): void {
162163
$updater->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($eventSource, $l) {
163164
$eventSource->send('success', $l->t('Updated "%1$s" to %2$s', [$app, $version]));
164165
});
165-
$updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps) {
166-
$incompatibleApps[] = $app;
166+
$updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use (&$incompatibleApps, &$incompatibleOverwrites) {
167+
if (!in_array($app, $incompatibleOverwrites)) {
168+
$incompatibleApps[] = $app;
169+
}
167170
});
168171
$updater->listen('\OC\Updater', 'failure', function ($message) use ($eventSource, $config) {
169172
$eventSource->send('failure', $message);

lib/base.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
* @author Lukas Reschke <lukas@statuscode.ch>
3636
* @author MartB <mart.b@outlook.de>
3737
* @author Michael Gapczynski <GapczynskiM@gmail.com>
38+
* @author MichaIng <micha@dietpi.com>
3839
* @author Morris Jobke <hey@morrisjobke.de>
3940
* @author Owen Winkler <a_github@midnightcircus.com>
4041
* @author Phil Davis <phil.davis@inf.org>
@@ -388,11 +389,16 @@ private static function printUpgradePage(\OC\SystemConfig $systemConfig): void {
388389
$ocVersion = \OCP\Util::getVersion();
389390
$ocVersion = implode('.', $ocVersion);
390391
$incompatibleApps = $appManager->getIncompatibleApps($ocVersion);
392+
$incompatibleOverwrites = $systemConfig->getValue('app_install_overwrite', []);
391393
$incompatibleShippedApps = [];
394+
$incompatibleDisabledApps = [];
392395
foreach ($incompatibleApps as $appInfo) {
393396
if ($appManager->isShipped($appInfo['id'])) {
394397
$incompatibleShippedApps[] = $appInfo['name'] . ' (' . $appInfo['id'] . ')';
395398
}
399+
if (!in_array($appInfo['id'], $incompatibleOverwrites)) {
400+
$incompatibleDisabledApps[] = $appInfo;
401+
}
396402
}
397403

398404
if (!empty($incompatibleShippedApps)) {
@@ -402,7 +408,7 @@ private static function printUpgradePage(\OC\SystemConfig $systemConfig): void {
402408
}
403409

404410
$tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion));
405-
$tmpl->assign('incompatibleAppsList', $incompatibleApps);
411+
$tmpl->assign('incompatibleAppsList', $incompatibleDisabledApps);
406412
try {
407413
$defaults = new \OC_Defaults();
408414
$tmpl->assign('productName', $defaults->getName());

0 commit comments

Comments
 (0)