diff --git a/apps/settings/lib/Controller/AppSettingsController.php b/apps/settings/lib/Controller/AppSettingsController.php index 7a1e5dd71571e..0c278664d629e 100644 --- a/apps/settings/lib/Controller/AppSettingsController.php +++ b/apps/settings/lib/Controller/AppSettingsController.php @@ -557,6 +557,8 @@ public function uninstallApp(string $appId): JSONResponse { $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]]); } diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml index fbc5a4ac4fc6a..5763a66482550 100644 --- a/build/psalm-baseline.xml +++ b/build/psalm-baseline.xml @@ -1035,6 +1035,7 @@ + diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index 2b6d2a2700bc4..73dedbd98dc63 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -410,12 +410,14 @@ public function isInstalled($appId) { 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 {