From 9e327a5890735d2a4dc3b7f88ab5fd571119c21d Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Wed, 23 Oct 2024 12:55:28 +0200 Subject: fix(apps-store): Remove apps from force-enabled state when uninstalled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Co-authored-by: Ferdinand Thiessen Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com> Signed-off-by: Ferdinand Thiessen --- apps/settings/lib/Controller/AppSettingsController.php | 8 +++++--- apps/settings/tests/Controller/AppSettingsControllerTest.php | 7 +++---- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'apps/settings') diff --git a/apps/settings/lib/Controller/AppSettingsController.php b/apps/settings/lib/Controller/AppSettingsController.php index 7affb0d5069..4d34b7678d7 100644 --- a/apps/settings/lib/Controller/AppSettingsController.php +++ b/apps/settings/lib/Controller/AppSettingsController.php @@ -6,6 +6,7 @@ */ namespace OCA\Settings\Controller; +use OC\App\AppManager; use OC\App\AppStore\Bundles\BundleFetcher; use OC\App\AppStore\Fetcher\AppDiscoverFetcher; use OC\App\AppStore\Fetcher\AppFetcher; @@ -15,7 +16,6 @@ use OC\App\DependencyAnalyzer; use OC\App\Platform; use OC\Installer; use OCP\App\AppPathNotFoundException; -use OCP\App\IAppManager; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; use OCP\AppFramework\Http\Attribute\NoCSRFRequired; @@ -62,7 +62,7 @@ class AppSettingsController extends Controller { private IL10N $l10n, private IConfig $config, private INavigationManager $navigationManager, - private IAppManager $appManager, + private AppManager $appManager, private CategoryFetcher $categoryFetcher, private AppFetcher $appFetcher, private IFactory $l10nFactory, @@ -592,6 +592,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->removeOverwriteNextcloudRequirement($appId); $this->appManager->clearAppsCache(); return new JSONResponse(['data' => ['appid' => $appId]]); } @@ -631,7 +633,7 @@ class AppSettingsController extends Controller { public function force(string $appId): JSONResponse { $appId = $this->appManager->cleanAppId($appId); - $this->appManager->ignoreNextcloudRequirementForApp($appId); + $this->appManager->overwriteNextcloudRequirement($appId); return new JSONResponse(); } } diff --git a/apps/settings/tests/Controller/AppSettingsControllerTest.php b/apps/settings/tests/Controller/AppSettingsControllerTest.php index c219ee2fc9f..f72bd45a3d2 100644 --- a/apps/settings/tests/Controller/AppSettingsControllerTest.php +++ b/apps/settings/tests/Controller/AppSettingsControllerTest.php @@ -6,13 +6,13 @@ */ namespace OCA\Settings\Tests\Controller; +use OC\App\AppManager; use OC\App\AppStore\Bundles\BundleFetcher; use OC\App\AppStore\Fetcher\AppDiscoverFetcher; use OC\App\AppStore\Fetcher\AppFetcher; use OC\App\AppStore\Fetcher\CategoryFetcher; use OC\Installer; use OCA\Settings\Controller\AppSettingsController; -use OCP\App\IAppManager; use OCP\AppFramework\Http\ContentSecurityPolicy; use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\Http\TemplateResponse; @@ -47,8 +47,7 @@ class AppSettingsControllerTest extends TestCase { private $config; /** @var INavigationManager|MockObject */ private $navigationManager; - /** @var IAppManager|MockObject */ - private $appManager; + private AppManager&MockObject $appManager; /** @var CategoryFetcher|MockObject */ private $categoryFetcher; /** @var AppFetcher|MockObject */ @@ -83,7 +82,7 @@ class AppSettingsControllerTest extends TestCase { ->willReturnArgument(0); $this->config = $this->createMock(IConfig::class); $this->navigationManager = $this->createMock(INavigationManager::class); - $this->appManager = $this->createMock(IAppManager::class); + $this->appManager = $this->createMock(AppManager::class); $this->categoryFetcher = $this->createMock(CategoryFetcher::class); $this->appFetcher = $this->createMock(AppFetcher::class); $this->l10nFactory = $this->createMock(IFactory::class); -- cgit v1.2.3