aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2025-02-10 11:25:50 +0100
committerCôme Chilliet <come.chilliet@nextcloud.com>2025-02-13 10:19:19 +0100
commita3685551f7188e7d2d0c7532b821ec2c3bd40583 (patch)
tree43aa4f911e53a66529152cb2ac44e017f0ef9f31
parentcffd2c8d09e9e9198aed4754478c18f4c8b7c201 (diff)
downloadnextcloud-server-a3685551f7188e7d2d0c7532b821ec2c3bd40583.tar.gz
nextcloud-server-a3685551f7188e7d2d0c7532b821ec2c3bd40583.zip
fix: Replace isInstalled calls with isEnabledForAnyone or isEnabledForUser
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
-rw-r--r--apps/comments/lib/Activity/Listener.php2
-rw-r--r--apps/comments/tests/Unit/Activity/ListenerTest.php2
-rw-r--r--apps/dav/lib/Connector/Sabre/Directory.php2
-rw-r--r--apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php2
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php2
-rw-r--r--apps/settings/lib/Controller/AppSettingsController.php4
-rw-r--r--apps/systemtags/lib/Activity/Listener.php2
-rw-r--r--apps/webhook_listeners/lib/BackgroundJobs/WebhookCall.php2
-rw-r--r--core/Command/App/Disable.php2
-rw-r--r--core/Command/App/Enable.php12
-rw-r--r--core/Command/App/Install.php2
-rw-r--r--core/Command/App/ListApps.php2
-rw-r--r--core/Command/App/Remove.php2
-rw-r--r--core/Command/Db/Migrations/GenerateMetadataCommand.php6
-rw-r--r--lib/base.php8
-rw-r--r--lib/private/Migration/MetadataManager.php2
-rw-r--r--lib/private/Server.php4
-rw-r--r--lib/private/TaskProcessing/Manager.php2
-rw-r--r--public.php2
-rw-r--r--remote.php2
-rw-r--r--tests/Core/Command/Apps/AppsEnableTest.php4
-rw-r--r--tests/lib/App/AppManagerTest.php6
22 files changed, 35 insertions, 39 deletions
diff --git a/apps/comments/lib/Activity/Listener.php b/apps/comments/lib/Activity/Listener.php
index b07cb19afda..45064f4a6be 100644
--- a/apps/comments/lib/Activity/Listener.php
+++ b/apps/comments/lib/Activity/Listener.php
@@ -31,7 +31,7 @@ class Listener {
public function commentEvent(CommentsEvent $event): void {
if ($event->getComment()->getObjectType() !== 'files'
|| $event->getEvent() !== CommentsEvent::EVENT_ADD
- || !$this->appManager->isInstalled('activity')) {
+ || !$this->appManager->isEnabledForAnyone('activity')) {
// Comment not for file, not adding a comment or no activity-app enabled (save the energy)
return;
}
diff --git a/apps/comments/tests/Unit/Activity/ListenerTest.php b/apps/comments/tests/Unit/Activity/ListenerTest.php
index 19dcae4c8ab..70dec741978 100644
--- a/apps/comments/tests/Unit/Activity/ListenerTest.php
+++ b/apps/comments/tests/Unit/Activity/ListenerTest.php
@@ -67,7 +67,7 @@ class ListenerTest extends TestCase {
public function testCommentEvent(): void {
$this->appManager->expects($this->any())
- ->method('isInstalled')
+ ->method('isEnabledForAnyone')
->with('activity')
->willReturn(true);
diff --git a/apps/dav/lib/Connector/Sabre/Directory.php b/apps/dav/lib/Connector/Sabre/Directory.php
index 7215723803f..26e16a867f4 100644
--- a/apps/dav/lib/Connector/Sabre/Directory.php
+++ b/apps/dav/lib/Connector/Sabre/Directory.php
@@ -220,7 +220,7 @@ class Directory extends Node implements \Sabre\DAV\ICollection, \Sabre\DAV\IQuot
if (!$this->info->isReadable()) {
// return 403 instead of 404 because a 404 would make
// the caller believe that the collection itself does not exist
- if (Server::get(IAppManager::class)->isInstalled('files_accesscontrol')) {
+ if (Server::get(IAppManager::class)->isEnabledForAnyone('files_accesscontrol')) {
throw new Forbidden('No read permissions. This might be caused by files_accesscontrol, check your configured rules');
} else {
throw new Forbidden('No read permissions');
diff --git a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php
index d5082eafc56..2de406940d7 100644
--- a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php
+++ b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php
@@ -746,7 +746,7 @@ class CloudFederationProviderFiles implements ISignedCloudFederationProvider {
public function getUserDisplayName(string $userId): string {
// check if gss is enabled and available
- if (!$this->appManager->isInstalled('globalsiteselector')
+ if (!$this->appManager->isEnabledForAnyone('globalsiteselector')
|| !class_exists('\OCA\GlobalSiteSelector\Service\SlaveService')) {
return '';
}
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index f6fc584529b..2e21f90943f 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -408,7 +408,7 @@ class ShareAPIController extends OCSController {
private function retrieveFederatedDisplayName(array $userIds, bool $cacheOnly = false): array {
// check if gss is enabled and available
if (count($userIds) === 0
- || !$this->appManager->isInstalled('globalsiteselector')
+ || !$this->appManager->isEnabledForAnyone('globalsiteselector')
|| !class_exists('\OCA\GlobalSiteSelector\Service\SlaveService')) {
return [];
}
diff --git a/apps/settings/lib/Controller/AppSettingsController.php b/apps/settings/lib/Controller/AppSettingsController.php
index 4d34b7678d7..24207d98543 100644
--- a/apps/settings/lib/Controller/AppSettingsController.php
+++ b/apps/settings/lib/Controller/AppSettingsController.php
@@ -92,7 +92,7 @@ class AppSettingsController extends Controller {
$this->initialState->provideInitialState('appstoreDeveloperDocs', $this->urlGenerator->linkToDocs('developer-manual'));
$this->initialState->provideInitialState('appstoreUpdateCount', count($this->getAppsWithUpdates()));
- if ($this->appManager->isInstalled('app_api')) {
+ if ($this->appManager->isEnabledForAnyone('app_api')) {
try {
Server::get(\OCA\AppAPI\Service\ExAppsPageService::class)->provideAppApiState($this->initialState);
} catch (\Psr\Container\NotFoundExceptionInterface|\Psr\Container\ContainerExceptionInterface $e) {
@@ -440,7 +440,7 @@ class AppSettingsController extends Controller {
}
$currentVersion = '';
- if ($this->appManager->isInstalled($app['id'])) {
+ if ($this->appManager->isEnabledForAnyone($app['id'])) {
$currentVersion = $this->appManager->getAppVersion($app['id']);
} else {
$currentVersion = $app['releases'][0]['version'];
diff --git a/apps/systemtags/lib/Activity/Listener.php b/apps/systemtags/lib/Activity/Listener.php
index d255ef2b91f..93e3f102c94 100644
--- a/apps/systemtags/lib/Activity/Listener.php
+++ b/apps/systemtags/lib/Activity/Listener.php
@@ -109,7 +109,7 @@ class Listener {
$tagIds = $event->getTags();
if ($event->getObjectType() !== 'files' || empty($tagIds)
|| !in_array($event->getEvent(), [MapperEvent::EVENT_ASSIGN, MapperEvent::EVENT_UNASSIGN])
- || !$this->appManager->isInstalled('activity')) {
+ || !$this->appManager->isEnabledForAnyone('activity')) {
// System tags not for files, no tags, not (un-)assigning or no activity-app enabled (save the energy)
return;
}
diff --git a/apps/webhook_listeners/lib/BackgroundJobs/WebhookCall.php b/apps/webhook_listeners/lib/BackgroundJobs/WebhookCall.php
index 997e8931703..a2619e0db47 100644
--- a/apps/webhook_listeners/lib/BackgroundJobs/WebhookCall.php
+++ b/apps/webhook_listeners/lib/BackgroundJobs/WebhookCall.php
@@ -60,7 +60,7 @@ class WebhookCall extends QueuedJob {
$exAppId = $webhookListener->getAppId();
if ($exAppId !== null && str_starts_with($webhookUri, '/')) {
// ExApp is awaiting a direct request to itself using AppAPI
- if (!$this->appManager->isInstalled('app_api')) {
+ if (!$this->appManager->isEnabledForAnyone('app_api')) {
throw new RuntimeException('AppAPI is disabled or not installed.');
}
try {
diff --git a/core/Command/App/Disable.php b/core/Command/App/Disable.php
index e1f9c2a4d72..a0a20ef21dd 100644
--- a/core/Command/App/Disable.php
+++ b/core/Command/App/Disable.php
@@ -44,7 +44,7 @@ class Disable extends Command implements CompletionAwareInterface {
}
private function disableApp(string $appId, OutputInterface $output): void {
- if ($this->appManager->isInstalled($appId) === false) {
+ if ($this->appManager->isEnabledForAnyone($appId) === false) {
$output->writeln('No such app enabled: ' . $appId);
return;
}
diff --git a/core/Command/App/Enable.php b/core/Command/App/Enable.php
index 5366230b841..3936acfbf6e 100644
--- a/core/Command/App/Enable.php
+++ b/core/Command/App/Enable.php
@@ -27,6 +27,7 @@ class Enable extends Command implements CompletionAwareInterface {
public function __construct(
protected IAppManager $appManager,
protected IGroupManager $groupManager,
+ private Installer $installer,
) {
parent::__construct();
}
@@ -77,20 +78,17 @@ class Enable extends Command implements CompletionAwareInterface {
return $group->getDisplayName();
}, $groupIds);
- if ($this->appManager->isInstalled($appId) && $groupIds === []) {
+ if ($this->appManager->isEnabledForUser($appId) && $groupIds === []) {
$output->writeln($appId . ' already enabled');
return;
}
try {
- /** @var Installer $installer */
- $installer = \OC::$server->query(Installer::class);
-
- if ($installer->isDownloaded($appId) === false) {
- $installer->downloadApp($appId);
+ if ($this->installer->isDownloaded($appId) === false) {
+ $this->installer->downloadApp($appId);
}
- $installer->installApp($appId, $forceEnable);
+ $this->installer->installApp($appId, $forceEnable);
$appVersion = $this->appManager->getAppVersion($appId);
if ($groupIds === []) {
diff --git a/core/Command/App/Install.php b/core/Command/App/Install.php
index 4e9c846cbd4..c8a396c8e36 100644
--- a/core/Command/App/Install.php
+++ b/core/Command/App/Install.php
@@ -58,7 +58,7 @@ class Install extends Command {
$appId = $input->getArgument('app-id');
$forceEnable = (bool)$input->getOption('force');
- if ($this->appManager->isInstalled($appId)) {
+ if ($this->appManager->isEnabledForAnyone($appId)) {
$output->writeln($appId . ' already installed');
return 1;
}
diff --git a/core/Command/App/ListApps.php b/core/Command/App/ListApps.php
index 6512c9e064c..5244d66e0d8 100644
--- a/core/Command/App/ListApps.php
+++ b/core/Command/App/ListApps.php
@@ -65,7 +65,7 @@ class ListApps extends Base {
if ($shippedFilter !== null && $this->manager->isShipped($app) !== $shippedFilter) {
continue;
}
- if ($this->manager->isInstalled($app)) {
+ if ($this->manager->isEnabledForAnyone($app)) {
$enabledApps[] = $app;
} else {
$disabledApps[] = $app;
diff --git a/core/Command/App/Remove.php b/core/Command/App/Remove.php
index 2ea10930427..fb3ca3f733d 100644
--- a/core/Command/App/Remove.php
+++ b/core/Command/App/Remove.php
@@ -50,7 +50,7 @@ class Remove extends Command implements CompletionAwareInterface {
$appId = $input->getArgument('app-id');
// Check if the app is enabled
- if (!$this->manager->isInstalled($appId)) {
+ if (!$this->manager->isEnabledForAnyone($appId)) {
$output->writeln($appId . ' is not enabled');
return 1;
}
diff --git a/core/Command/Db/Migrations/GenerateMetadataCommand.php b/core/Command/Db/Migrations/GenerateMetadataCommand.php
index ae83f92b29e..581259c99df 100644
--- a/core/Command/Db/Migrations/GenerateMetadataCommand.php
+++ b/core/Command/Db/Migrations/GenerateMetadataCommand.php
@@ -68,15 +68,11 @@ class GenerateMetadataCommand extends Command {
$metadata = [];
foreach ($allApps as $appId) {
// We need to load app before being able to extract Migrations
- // If app was not enabled before, we will disable it afterward.
- $alreadyLoaded = $this->appManager->isInstalled($appId);
+ $alreadyLoaded = $this->appManager->isAppLoaded($appId);
if (!$alreadyLoaded) {
$this->appManager->loadApp($appId);
}
$metadata[$appId] = $this->metadataManager->extractMigrationAttributes($appId);
- if (!$alreadyLoaded) {
- $this->appManager->disableApp($appId);
- }
}
return $metadata;
}
diff --git a/lib/base.php b/lib/base.php
index 25f978df836..9323cb735ca 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -255,7 +255,7 @@ class OC {
$tooBig = false;
if (!$disableWebUpdater) {
$apps = Server::get(\OCP\App\IAppManager::class);
- if ($apps->isInstalled('user_ldap')) {
+ if ($apps->isEnabledForAnyone('user_ldap')) {
$qb = Server::get(\OCP\IDBConnection::class)->getQueryBuilder();
$result = $qb->select($qb->func()->count('*', 'user_count'))
@@ -266,7 +266,7 @@ class OC {
$tooBig = ($row['user_count'] > 50);
}
- if (!$tooBig && $apps->isInstalled('user_saml')) {
+ if (!$tooBig && $apps->isEnabledForAnyone('user_saml')) {
$qb = Server::get(\OCP\IDBConnection::class)->getQueryBuilder();
$result = $qb->select($qb->func()->count('*', 'user_count'))
@@ -1130,11 +1130,11 @@ class OC {
}
protected static function tryAppAPILogin(OCP\IRequest $request): bool {
- $appManager = Server::get(OCP\App\IAppManager::class);
if (!$request->getHeader('AUTHORIZATION-APP-API')) {
return false;
}
- if (!$appManager->isInstalled('app_api')) {
+ $appManager = Server::get(OCP\App\IAppManager::class);
+ if (!$appManager->isEnabledForAnyone('app_api')) {
return false;
}
try {
diff --git a/lib/private/Migration/MetadataManager.php b/lib/private/Migration/MetadataManager.php
index fac9127a123..84924a8fb18 100644
--- a/lib/private/Migration/MetadataManager.php
+++ b/lib/private/Migration/MetadataManager.php
@@ -73,7 +73,7 @@ class MetadataManager {
): array {
$appsAttributes = [];
foreach (array_keys($metadata['apps']) as $appId) {
- if ($filterKnownMigrations && !$this->appManager->isInstalled($appId)) {
+ if ($filterKnownMigrations && !$this->appManager->isEnabledForAnyone($appId)) {
continue; // if not interested and app is not installed
}
diff --git a/lib/private/Server.php b/lib/private/Server.php
index be9d7595e42..968d469aa74 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -837,7 +837,7 @@ class Server extends ServerContainer implements IServerContainer {
$busClass = $c->get(\OCP\IConfig::class)->getSystemValueString('commandbus');
if ($busClass) {
[$app, $class] = explode('::', $busClass, 2);
- if ($c->get(IAppManager::class)->isInstalled($app)) {
+ if ($c->get(IAppManager::class)->isEnabledForUser($app)) {
\OC_App::loadApp($app);
return $c->get($class);
} else {
@@ -1046,7 +1046,7 @@ class Server extends ServerContainer implements IServerContainer {
$classExists = false;
}
- if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValueBool('installed', false) && $c->get(IAppManager::class)->isInstalled('theming') && $c->get(TrustedDomainHelper::class)->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
+ if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValueBool('installed', false) && $c->get(IAppManager::class)->isEnabledForAnyone('theming') && $c->get(TrustedDomainHelper::class)->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
$backgroundService = new BackgroundService(
$c->get(IRootFolder::class),
$c->getAppDataDir('theming'),
diff --git a/lib/private/TaskProcessing/Manager.php b/lib/private/TaskProcessing/Manager.php
index 0c8d2414448..07e643ab004 100644
--- a/lib/private/TaskProcessing/Manager.php
+++ b/lib/private/TaskProcessing/Manager.php
@@ -1396,7 +1396,7 @@ class Manager implements IManager {
$this->logger->warning('Task processing AppAPI webhook failed for task ' . $task->getId() . '. Invalid method: ' . $method);
}
[, $exAppId, $httpMethod] = $parsedMethod;
- if (!$this->appManager->isInstalled('app_api')) {
+ if (!$this->appManager->isEnabledForAnyone('app_api')) {
$this->logger->warning('Task processing AppAPI webhook failed for task ' . $task->getId() . '. AppAPI is disabled or not installed.');
return;
}
diff --git a/public.php b/public.php
index f6d0b0a7940..fc0e78695c9 100644
--- a/public.php
+++ b/public.php
@@ -70,7 +70,7 @@ try {
OC_App::loadApps(['filesystem', 'logging']);
// Check if the app is enabled
- if (!\OC::$server->getAppManager()->isInstalled($app)) {
+ if (!\OC::$server->getAppManager()->isEnabledForUser($app)) {
throw new \Exception('App not installed: ' . $app);
}
diff --git a/remote.php b/remote.php
index bc97de7bcb3..f63fd49354a 100644
--- a/remote.php
+++ b/remote.php
@@ -134,7 +134,7 @@ try {
$file = OC::$SERVERROOT . '/' . $file;
break;
default:
- if (!$appManager->isInstalled($app)) {
+ if (!$appManager->isEnabledForUser($app)) {
throw new RemoteException('App not installed: ' . $app);
}
$appManager->loadApp($app);
diff --git a/tests/Core/Command/Apps/AppsEnableTest.php b/tests/Core/Command/Apps/AppsEnableTest.php
index 228c09364bf..5e7a4215286 100644
--- a/tests/Core/Command/Apps/AppsEnableTest.php
+++ b/tests/Core/Command/Apps/AppsEnableTest.php
@@ -9,6 +9,7 @@ declare(strict_types=1);
namespace Tests\Core\Command\Config;
use OC\Core\Command\App\Enable;
+use OC\Installer;
use Symfony\Component\Console\Tester\CommandTester;
use Test\TestCase;
@@ -26,7 +27,8 @@ class AppsEnableTest extends TestCase {
$command = new Enable(
\OC::$server->getAppManager(),
- \OC::$server->getGroupManager()
+ \OC::$server->getGroupManager(),
+ \OC::$server->get(Installer::class),
);
$this->commandTester = new CommandTester($command);
diff --git a/tests/lib/App/AppManagerTest.php b/tests/lib/App/AppManagerTest.php
index fd7a065d5b3..a9cd4f708a5 100644
--- a/tests/lib/App/AppManagerTest.php
+++ b/tests/lib/App/AppManagerTest.php
@@ -426,17 +426,17 @@ class AppManagerTest extends TestCase {
public function testIsInstalledEnabled(): void {
$this->appConfig->setValue('test', 'enabled', 'yes');
- $this->assertTrue($this->manager->isInstalled('test'));
+ $this->assertTrue($this->manager->isEnabledForAnyone('test'));
}
public function testIsInstalledDisabled(): void {
$this->appConfig->setValue('test', 'enabled', 'no');
- $this->assertFalse($this->manager->isInstalled('test'));
+ $this->assertFalse($this->manager->isEnabledForAnyone('test'));
}
public function testIsInstalledEnabledForGroups(): void {
$this->appConfig->setValue('test', 'enabled', '["foo"]');
- $this->assertTrue($this->manager->isInstalled('test'));
+ $this->assertTrue($this->manager->isEnabledForAnyone('test'));
}
private function newUser($uid) {