Skip to content

Commit

Permalink
Hide overwrites from disabled apps list on upgrade
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
MichaIng committed May 3, 2023
1 parent 2c60ad8 commit ec05b2a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
7 changes: 5 additions & 2 deletions core/Command/Upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->logger,
$this->installer
);
$incompatibleOverwrites = $this->config->getSystemValue('app_install_overwrite', []);

/** @var IEventDispatcher $dispatcher */
$dispatcher = \OC::$server->get(IEventDispatcher::class);
Expand Down Expand Up @@ -191,8 +192,10 @@ function ($success) use ($output, $self) {
$updater->listen('\OC\Updater', 'dbUpgrade', function () use ($output) {
$output->writeln('<info>Updated database</info>');
});
$updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use ($output) {
$output->writeln('<comment>Disabled incompatible app: ' . $app . '</comment>');
$updater->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use ($output, &$incompatibleOverwrites) {
if (!in_array($app, $incompatibleOverwrites)) {
$output->writeln('<comment>Disabled incompatible app: ' . $app . '</comment>');
}
});
$updater->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use ($output) {
$output->writeln('<info>Update app ' . $app . ' from App Store</info>');
Expand Down
7 changes: 5 additions & 2 deletions core/ajax/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public function handleRepairFeedback(Event $event): void {
\OC::$server->query(\OC\Installer::class)
);
$incompatibleApps = [];
$incompatibleOverwrites = $config->getSystemValue('app_install_overwrite', []);

/** @var IEventDispatcher $dispatcher */
$dispatcher = \OC::$server->get(IEventDispatcher::class);
Expand Down Expand Up @@ -160,8 +161,10 @@ function (MigratorExecuteSqlEvent $event) use ($eventSource, $l): void {
$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);
Expand Down
8 changes: 7 additions & 1 deletion lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* @author Lukas Reschke <[email protected]>
* @author MartB <[email protected]>
* @author Michael Gapczynski <[email protected]>
* @author MichaIng <[email protected]>
* @author Morris Jobke <[email protected]>
* @author Owen Winkler <[email protected]>
* @author Phil Davis <[email protected]>
Expand Down Expand Up @@ -385,11 +386,16 @@ private static function printUpgradePage(\OC\SystemConfig $systemConfig): void {
$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)) {
Expand All @@ -399,7 +405,7 @@ private static function printUpgradePage(\OC\SystemConfig $systemConfig): void {
}

$tmpl->assign('appsToUpgrade', $appManager->getAppsNeedingUpgrade($ocVersion));
$tmpl->assign('incompatibleAppsList', $incompatibleApps);
$tmpl->assign('incompatibleAppsList', $incompatibleDisabledApps);
try {
$defaults = new \OC_Defaults();
$tmpl->assign('productName', $defaults->getName());
Expand Down

0 comments on commit ec05b2a

Please sign in to comment.