diff options
author | Joas Schilling <coding@schilljs.com> | 2021-10-01 16:40:25 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2021-10-13 09:34:55 +0200 |
commit | 0b747538ff2849b3e27a8fcf3b68c5b8007b28d9 (patch) | |
tree | ee9a1763f33ac1042627c745e77f034e3da59ba9 /lib | |
parent | 1ea5983568dc99aa80e52f18837629d137b8a03c (diff) | |
download | nextcloud-server-0b747538ff2849b3e27a8fcf3b68c5b8007b28d9.tar.gz nextcloud-server-0b747538ff2849b3e27a8fcf3b68c5b8007b28d9.zip |
Keep group restrictions when reenabling apps after an update
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/App/AppManager.php | 6 | ||||
-rw-r--r-- | lib/private/Updater.php | 17 | ||||
-rw-r--r-- | lib/public/App/IAppManager.php | 6 |
3 files changed, 18 insertions, 11 deletions
diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index 388a743b936..b1f3097cc3d 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -391,7 +391,11 @@ class AppManager implements IAppManager { } if ($automaticDisabled) { - $this->autoDisabledApps[] = $appId; + $previousSetting = $this->appConfig->getValue($appId, 'enabled', 'yes'); + if ($previousSetting !== 'yes' && $previousSetting !== 'no') { + $previousSetting = json_decode($previousSetting, true); + } + $this->autoDisabledApps[$appId] = $previousSetting; } unset($this->installedAppsCache[$appId]); diff --git a/lib/private/Updater.php b/lib/private/Updater.php index 4ddb5e2b7cb..6494f7efe0d 100644 --- a/lib/private/Updater.php +++ b/lib/private/Updater.php @@ -40,11 +40,13 @@ declare(strict_types=1); */ namespace OC; +use OC\App\AppManager; use OC\DB\Connection; use OC\DB\MigrationService; use OC\Hooks\BasicEmitter; use OC\IntegrityCheck\Checker; use OC_App; +use OCP\App\IAppManager; use OCP\HintException; use OCP\IConfig; use OCP\ILogger; @@ -265,9 +267,12 @@ class Updater extends BasicEmitter { // Update the appfetchers version so it downloads the correct list from the appstore \OC::$server->getAppFetcher()->setVersion($currentVersion); + /** @var IAppManager|AppManager $appManager */ + $appManager = \OC::$server->getAppManager(); + // upgrade appstore apps - $this->upgradeAppStoreApps(\OC::$server->getAppManager()->getInstalledApps()); - $autoDisabledApps = \OC::$server->getAppManager()->getAutoDisabledApps(); + $this->upgradeAppStoreApps($appManager->getInstalledApps()); + $autoDisabledApps = $appManager->getAutoDisabledApps(); $this->upgradeAppStoreApps($autoDisabledApps, true); // install new shipped apps on upgrade @@ -400,7 +405,7 @@ class Updater extends BasicEmitter { * @throws \Exception */ private function upgradeAppStoreApps(array $disabledApps, bool $reenable = false): void { - foreach ($disabledApps as $app) { + foreach ($disabledApps as $app => $previousEnableSetting) { try { $this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]); if ($this->installer->isUpdateAvailable($app)) { @@ -411,7 +416,11 @@ class Updater extends BasicEmitter { if ($reenable) { $ocApp = new \OC_App(); - $ocApp->enable($app); + if (!empty($previousEnableSetting)) { + $ocApp->enable($app, $previousEnableSetting); + } else { + $ocApp->enable($app); + } } } catch (\Exception $ex) { $this->log->error($ex->getMessage(), [ diff --git a/lib/public/App/IAppManager.php b/lib/public/App/IAppManager.php index 645d5ffd97c..7473b229427 100644 --- a/lib/public/App/IAppManager.php +++ b/lib/public/App/IAppManager.php @@ -183,12 +183,6 @@ interface IAppManager { public function getEnabledAppsForGroup(IGroup $group): array; /** - * @return array - * @since 17.0.0 - */ - public function getAutoDisabledApps(): array; - - /** * @param String $appId * @return string[] * @since 17.0.0 |