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

[stable21] Fix app upgrade #29302

Merged
merged 1 commit into from
Oct 19, 2021
Merged
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
18 changes: 10 additions & 8 deletions lib/private/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,9 @@ private function doUpgrade($currentVersion, $installedVersion) {
// upgrade appstore apps
$this->upgradeAppStoreApps($appManager->getInstalledApps());
$autoDisabledApps = $appManager->getAutoDisabledApps();
$this->upgradeAppStoreApps($autoDisabledApps, true);
if (!empty($autoDisabledApps)) {
$this->upgradeAppStoreApps(array_keys($autoDisabledApps), $autoDisabledApps);
}

// install new shipped apps on upgrade
$errors = Installer::installShippedApps(true);
Expand Down Expand Up @@ -409,12 +411,12 @@ private function isCodeUpgrade() {
}

/**
* @param array $disabledApps
* @param bool $reenable
* @param array $apps
* @param array $previousEnableStates
* @throws \Exception
*/
private function upgradeAppStoreApps(array $disabledApps, $reenable = false) {
foreach ($disabledApps as $app => $previousEnableSetting) {
private function upgradeAppStoreApps(array $apps, array $previousEnableStates = []) {
foreach ($apps as $app) {
try {
$this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]);
if ($this->installer->isUpdateAvailable($app)) {
Expand All @@ -423,10 +425,10 @@ private function upgradeAppStoreApps(array $disabledApps, $reenable = false) {
}
$this->emit('\OC\Updater', 'checkAppStoreApp', [$app]);

if ($reenable) {
if (!empty($previousEnableStates)) {
$ocApp = new \OC_App();
if (!empty($previousEnableSetting)) {
$ocApp->enable($app, $previousEnableSetting);
if (!empty($previousEnableStates[$app])) {
$ocApp->enable($app, $previousEnableStates[$app]);
} else {
$ocApp->enable($app);
}
Expand Down