diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2021-10-13 22:24:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-13 22:24:18 +0200 |
commit | 7aa440b51d1eb67d449656c57103a18493cadbd7 (patch) | |
tree | 58139f3586557cf101c20c63271c222cad1b0540 /lib | |
parent | 8d43f26484827e0fd67e1ca9067ef51b2db92250 (diff) | |
parent | 7f4b3fb68d33b90f815ed26a249ecadbffbd2a48 (diff) | |
download | nextcloud-server-7aa440b51d1eb67d449656c57103a18493cadbd7.tar.gz nextcloud-server-7aa440b51d1eb67d449656c57103a18493cadbd7.zip |
Merge pull request #29197 from nextcloud/backport/29020/stable21
[stable21] Keep group restrictions when reenabling apps after an update
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 7063878429a..ae5aeab9831 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -400,7 +400,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 65e2c9bd57f..705ee435d57 100644 --- a/lib/private/Updater.php +++ b/lib/private/Updater.php @@ -37,11 +37,13 @@ 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\IConfig; use OCP\ILogger; use OCP\Util; @@ -262,9 +264,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 @@ -409,7 +414,7 @@ class Updater extends BasicEmitter { * @throws \Exception */ private function upgradeAppStoreApps(array $disabledApps, $reenable = false) { - foreach ($disabledApps as $app) { + foreach ($disabledApps as $app => $previousEnableSetting) { try { $this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]); if ($this->installer->isUpdateAvailable($app)) { @@ -420,7 +425,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->logException($ex, ['app' => 'core']); diff --git a/lib/public/App/IAppManager.php b/lib/public/App/IAppManager.php index 9ead8089c7d..78c60e2d6ab 100644 --- a/lib/public/App/IAppManager.php +++ b/lib/public/App/IAppManager.php @@ -184,12 +184,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 |