Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(updater): hide overwrites from disabled apps list on upgrade #29988

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions core/Command/Upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@

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

/** @var IEventDispatcher $dispatcher */
$dispatcher = \OC::$server->get(IEventDispatcher::class);
Expand Down Expand Up @@ -179,8 +180,10 @@
$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) {

Check notice

Code scanning / Psalm

DeprecatedMethod Note

The method OC\Hooks\EmitterTrait::listen has been marked as deprecated

Check notice

Code scanning / Psalm

MissingClosureParamType Note

Parameter $app has no provided type
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 @@ -120,6 +120,7 @@
\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 @@ -162,8 +163,10 @@
$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) {

Check notice

Code scanning / Psalm

DeprecatedMethod Note

The method OC\Hooks\EmitterTrait::listen has been marked as deprecated

Check notice

Code scanning / Psalm

MissingClosureParamType Note

Parameter $app has no provided type
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 @@ -201,7 +202,7 @@
// slash which is required by URL generation.
if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'] === \OC::$WEBROOT &&
substr($_SERVER['REQUEST_URI'], -1) !== '/') {
header('Location: '.\OC::$WEBROOT.'/');

Check failure on line 205 in lib/base.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-security

TaintedHeader

lib/base.php:205:12: TaintedHeader: Detected tainted header (see https://psalm.dev/256)
exit();
}
}
Expand Down Expand Up @@ -283,7 +284,7 @@
throw new Exception('Not installed');
} else {
$url = OC::$WEBROOT . '/index.php';
header('Location: ' . $url);

Check failure on line 287 in lib/base.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-security

TaintedHeader

lib/base.php:287:12: TaintedHeader: Detected tainted header (see https://psalm.dev/256)
}
exit();
}
Expand Down Expand Up @@ -388,11 +389,16 @@
$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 @@ -402,7 +408,7 @@
}

$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
Loading