From 7f4b3fb68d33b90f815ed26a249ecadbffbd2a48 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 1 Oct 2021 16:40:25 +0200 Subject: Keep group restrictions when reenabling apps after an update Signed-off-by: Joas Schilling --- lib/private/App/AppManager.php | 6 +++++- lib/private/Updater.php | 17 +++++++++++++---- lib/public/App/IAppManager.php | 6 ------ 3 files changed, 18 insertions(+), 11 deletions(-) (limited to 'lib') 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 @@ -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[] -- cgit v1.2.3