Fix app upgrade

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/29259/head
Joas Schilling 3 years ago
parent 4e32fe8a4e
commit 59cf2b1789
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA

@ -273,7 +273,9 @@ class Updater extends BasicEmitter {
// upgrade appstore apps // upgrade appstore apps
$this->upgradeAppStoreApps($appManager->getInstalledApps()); $this->upgradeAppStoreApps($appManager->getInstalledApps());
$autoDisabledApps = $appManager->getAutoDisabledApps(); $autoDisabledApps = $appManager->getAutoDisabledApps();
$this->upgradeAppStoreApps($autoDisabledApps, true); if (!empty($autoDisabledApps)) {
$this->upgradeAppStoreApps(array_keys($autoDisabledApps), $autoDisabledApps);
}
// install new shipped apps on upgrade // install new shipped apps on upgrade
$errors = Installer::installShippedApps(true); $errors = Installer::installShippedApps(true);
@ -400,12 +402,12 @@ class Updater extends BasicEmitter {
} }
/** /**
* @param array $disabledApps * @param array $apps
* @param bool $reenable * @param array $previousEnableStates
* @throws \Exception * @throws \Exception
*/ */
private function upgradeAppStoreApps(array $disabledApps, bool $reenable = false): void { private function upgradeAppStoreApps(array $apps, array $previousEnableStates = []): void {
foreach ($disabledApps as $app => $previousEnableSetting) { foreach ($apps as $app) {
try { try {
$this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]); $this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]);
if ($this->installer->isUpdateAvailable($app)) { if ($this->installer->isUpdateAvailable($app)) {
@ -414,10 +416,10 @@ class Updater extends BasicEmitter {
} }
$this->emit('\OC\Updater', 'checkAppStoreApp', [$app]); $this->emit('\OC\Updater', 'checkAppStoreApp', [$app]);
if ($reenable) { if (!empty($previousEnableStates)) {
$ocApp = new \OC_App(); $ocApp = new \OC_App();
if (!empty($previousEnableSetting)) { if (!empty($previousEnableStates[$app])) {
$ocApp->enable($app, $previousEnableSetting); $ocApp->enable($app, $previousEnableStates[$app]);
} else { } else {
$ocApp->enable($app); $ocApp->enable($app);
} }

Loading…
Cancel
Save