]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(apps-store): Remove apps from force-enabled state when uninstalled
authorFerdinand Thiessen <opensource@fthiessen.de>
Wed, 23 Oct 2024 10:55:28 +0000 (12:55 +0200)
committerFerdinand Thiessen <opensource@fthiessen.de>
Wed, 23 Oct 2024 11:02:06 +0000 (13:02 +0200)
If an app is force-enabled and then uninstalled the force-enabled state was kept.
This is now removed, so when the app should be re-installed the compatibility should be reevaluated.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
apps/settings/lib/Controller/AppSettingsController.php
lib/private/App/AppManager.php

index 9622b66a16526bfc212be006185f82aef8aab743..f50338c3923598661d3f16e83467f350867a45b4 100644 (file)
@@ -557,6 +557,8 @@ class AppSettingsController extends Controller {
                $appId = $this->appManager->cleanAppId($appId);
                $result = $this->installer->removeApp($appId);
                if ($result !== false) {
+                       // If this app was force enabled, remove the force-enabled-state
+                       $this->appManager->ignoreNextcloudRequirementForApp($appId, false);
                        $this->appManager->clearAppsCache();
                        return new JSONResponse(['data' => ['appid' => $appId]]);
                }
index 2b6d2a2700bc49c5574e06e08187c01a7d65be17..73dedbd98dc6355212fe27b55bd6405673607a47 100644 (file)
@@ -410,12 +410,14 @@ class AppManager implements IAppManager {
                return isset($installedApps[$appId]);
        }
 
-       public function ignoreNextcloudRequirementForApp(string $appId): void {
+       public function ignoreNextcloudRequirementForApp(string $appId, bool $enabled = true): void {
                $ignoreMaxApps = $this->config->getSystemValue('app_install_overwrite', []);
-               if (!in_array($appId, $ignoreMaxApps, true)) {
+               if ($enabled && !in_array($appId, $ignoreMaxApps, true)) {
                        $ignoreMaxApps[] = $appId;
-                       $this->config->setSystemValue('app_install_overwrite', $ignoreMaxApps);
+               } elseif ($enabled === false) {
+                       $ignoreMaxApps = array_filter($ignoreMaxApps, fn (string $id) => $id !== $appId);
                }
+               $this->config->setSystemValue('app_install_overwrite', $ignoreMaxApps);
        }
 
        public function loadApp(string $app): void {