Skip to content

Commit

Permalink
Fix app upgrade
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Oct 19, 2021
1 parent efaf112 commit 2f6bd56
Showing 1 changed file with 10 additions and 8 deletions.
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

0 comments on commit 2f6bd56

Please sign in to comment.