]> source.dussan.org Git - nextcloud-server.git/commitdiff
Keep group restrictions when reenabling apps after an update 29020/head
authorJoas Schilling <coding@schilljs.com>
Fri, 1 Oct 2021 14:40:25 +0000 (16:40 +0200)
committerJoas Schilling <coding@schilljs.com>
Wed, 13 Oct 2021 07:34:55 +0000 (09:34 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/App/AppManager.php
lib/private/Updater.php
lib/public/App/IAppManager.php

index 388a743b93696cd1b73f96e65ac90e2abcbec461..b1f3097cc3d94f492b225b2759da9d249cfab762 100644 (file)
@@ -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]);
index 4ddb5e2b7cb92d54a584565b7da0b530f68e217d..6494f7efe0d82da84f594cf755c0302ee3f3af7a 100644 (file)
@@ -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(), [
index 645d5ffd97c9a4cb508d981c1f21e22b5fd58c55..7473b22942713f46abe8d24d5fcb8bd5a3f14305 100644 (file)
@@ -182,12 +182,6 @@ interface IAppManager {
         */
        public function getEnabledAppsForGroup(IGroup $group): array;
 
-       /**
-        * @return array
-        * @since 17.0.0
-        */
-       public function getAutoDisabledApps(): array;
-
        /**
         * @param String $appId
         * @return string[]