Merge pull request #49648 from nextcloud/fix/clarify-app-manager-methods

Clarify app manager method names
pull/50794/head
Côme Chilliet 8 months ago committed by GitHub
commit ed9b47462f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      apps/comments/lib/Activity/Listener.php
  2. 2
      apps/comments/tests/Unit/Activity/ListenerTest.php
  3. 2
      apps/dav/lib/AppInfo/PluginManager.php
  4. 2
      apps/dav/lib/Connector/Sabre/Directory.php
  5. 2
      apps/dav/tests/unit/AppInfo/PluginManagerTest.php
  6. 2
      apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php
  7. 2
      apps/files_sharing/lib/Controller/ShareAPIController.php
  8. 2
      apps/files_trashbin/lib/AppInfo/Application.php
  9. 2
      apps/files_versions/lib/AppInfo/Application.php
  10. 4
      apps/settings/lib/Controller/AppSettingsController.php
  11. 2
      apps/systemtags/lib/Activity/Listener.php
  12. 2
      apps/updatenotification/lib/BackgroundJob/UpdateAvailableNotifications.php
  13. 2
      apps/updatenotification/lib/Command/Check.php
  14. 2
      apps/updatenotification/lib/Controller/APIController.php
  15. 2
      apps/updatenotification/tests/BackgroundJob/UpdateAvailableNotificationsTest.php
  16. 2
      apps/webhook_listeners/lib/BackgroundJobs/WebhookCall.php
  17. 2
      core/Command/App/Disable.php
  18. 12
      core/Command/App/Enable.php
  19. 2
      core/Command/App/Install.php
  20. 2
      core/Command/App/ListApps.php
  21. 4
      core/Command/App/Remove.php
  22. 6
      core/Command/Db/Migrations/GenerateMetadataCommand.php
  23. 2
      core/Command/Maintenance/Repair.php
  24. 8
      lib/base.php
  25. 63
      lib/private/App/AppManager.php
  26. 2
      lib/private/Console/Application.php
  27. 4
      lib/private/Migration/MetadataManager.php
  28. 2
      lib/private/NavigationManager.php
  29. 4
      lib/private/Server.php
  30. 2
      lib/private/TaskProcessing/Manager.php
  31. 2
      lib/private/Template/JSConfigHelper.php
  32. 2
      lib/private/Updater.php
  33. 2
      lib/private/legacy/OC_App.php
  34. 17
      lib/public/App/IAppManager.php
  35. 2
      public.php
  36. 2
      remote.php
  37. 4
      tests/Core/Command/Apps/AppsEnableTest.php
  38. 10
      tests/lib/App/AppManagerTest.php
  39. 4
      tests/lib/NavigationManagerTest.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;
}

@ -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);

@ -119,7 +119,7 @@ class PluginManager {
$this->calendarPlugins[] = $this->container->get(AppCalendarPlugin::class);
foreach ($this->appManager->getInstalledApps() as $app) {
foreach ($this->appManager->getEnabledApps() as $app) {
// load plugins and collections from info.xml
$info = $this->appManager->getAppInfo($app);
if (!isset($info['types']) || !in_array('dav', $info['types'], true)) {

@ -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');

@ -24,7 +24,7 @@ class PluginManagerTest extends TestCase {
$server = $this->createMock(ServerContainer::class);
$appManager = $this->createMock(AppManager::class);
$appManager->method('getInstalledApps')
$appManager->method('getEnabledApps')
->willReturn(['adavapp', 'adavapp2']);
$appInfo1 = [

@ -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 '';
}

@ -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 [];
}

@ -74,7 +74,7 @@ class Application extends App implements IBootstrap {
}
public function registerTrashBackends(ContainerInterface $serverContainer, LoggerInterface $logger, IAppManager $appManager, ITrashManager $trashManager): void {
foreach ($appManager->getInstalledApps() as $app) {
foreach ($appManager->getEnabledApps() as $app) {
$appInfo = $appManager->getAppInfo($app);
if (isset($appInfo['trash'])) {
$backends = $appInfo['trash'];

@ -114,7 +114,7 @@ class Application extends App implements IBootstrap {
}
public function registerVersionBackends(ContainerInterface $container, IAppManager $appManager, LoggerInterface $logger): void {
foreach ($appManager->getInstalledApps() as $app) {
foreach ($appManager->getEnabledApps() as $app) {
$appInfo = $appManager->getAppInfo($app);
if (isset($appInfo['versions'])) {
$backends = $appInfo['versions'];

@ -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'];

@ -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;
}

@ -132,7 +132,7 @@ class UpdateAvailableNotifications extends TimedJob {
* Check all installed apps for updates
*/
protected function checkAppUpdates() {
$apps = $this->appManager->getInstalledApps();
$apps = $this->appManager->getEnabledApps();
foreach ($apps as $app) {
$update = $this->isUpdateAvailable($app);
if ($update !== false) {

@ -56,7 +56,7 @@ class Check extends Command {
// Apps
$apps = $this->appManager->getInstalledApps();
$apps = $this->appManager->getEnabledApps();
foreach ($apps as $app) {
$update = $this->installer->isUpdateAvailable($app);
if ($update !== false) {

@ -75,7 +75,7 @@ class APIController extends OCSController {
}
// Get list of installed custom apps
$installedApps = $this->appManager->getInstalledApps();
$installedApps = $this->appManager->getEnabledApps();
$installedApps = array_filter($installedApps, function ($app) {
try {
$this->appManager->getAppPath($app);

@ -244,7 +244,7 @@ class UpdateAvailableNotificationsTest extends TestCase {
]);
$this->appManager->expects($this->once())
->method('getInstalledApps')
->method('getEnabledApps')
->willReturn($apps);
$job->expects($this->exactly(\count($apps)))

@ -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 {

@ -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;
}

@ -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 === []) {

@ -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;
}

@ -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;

@ -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;
}
@ -117,7 +117,7 @@ class Remove extends Command implements CompletionAwareInterface {
*/
public function completeArgumentValues($argumentName, CompletionContext $context): array {
if ($argumentName === 'app-id') {
return $this->manager->getInstalledApps();
return $this->manager->getEnabledApps();
}
return [];
}

@ -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;
}

@ -61,7 +61,7 @@ class Repair extends Command {
$this->repair->addStep($step);
}
$apps = $this->appManager->getInstalledApps();
$apps = $this->appManager->getEnabledApps();
foreach ($apps as $app) {
if (!$this->appManager->isEnabledForUser($app)) {
continue;

@ -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 {

@ -45,7 +45,7 @@ class AppManager implements IAppManager {
];
/** @var string[] $appId => $enabled */
private array $installedAppsCache = [];
private array $enabledAppsCache = [];
/** @var string[]|null */
private ?array $shippedApps = null;
@ -129,10 +129,12 @@ class AppManager implements IAppManager {
}
/**
* @return string[] $appId => $enabled
* For all enabled apps, return the value of their 'enabled' config key.
*
* @return array<string,string> appId => enabled (may be 'yes', or a json encoded list of group ids)
*/
private function getInstalledAppsValues(): array {
if (!$this->installedAppsCache) {
private function getEnabledAppsValues(): array {
if (!$this->enabledAppsCache) {
$values = $this->getAppConfig()->getValues(false, 'enabled');
$alwaysEnabledApps = $this->getAlwaysEnabledApps();
@ -140,21 +142,30 @@ class AppManager implements IAppManager {
$values[$appId] = 'yes';
}
$this->installedAppsCache = array_filter($values, function ($value) {
$this->enabledAppsCache = array_filter($values, function ($value) {
return $value !== 'no';
});
ksort($this->installedAppsCache);
ksort($this->enabledAppsCache);
}
return $this->installedAppsCache;
return $this->enabledAppsCache;
}
/**
* List all installed apps
* Deprecated alias
*
* @return string[]
*/
public function getInstalledApps() {
return array_keys($this->getInstalledAppsValues());
return $this->getEnabledApps();
}
/**
* List all enabled apps, either for everyone or for some groups
*
* @return list<string>
*/
public function getEnabledApps(): array {
return array_keys($this->getEnabledAppsValues());
}
/**
@ -195,7 +206,7 @@ class AppManager implements IAppManager {
* @return string[]
*/
public function getEnabledAppsForUser(IUser $user) {
$apps = $this->getInstalledAppsValues();
$apps = $this->getEnabledAppsValues();
$appsForUser = array_filter($apps, function ($enabled) use ($user) {
return $this->checkAppForUser($enabled, $user);
});
@ -203,7 +214,7 @@ class AppManager implements IAppManager {
}
public function getEnabledAppsForGroup(IGroup $group): array {
$apps = $this->getInstalledAppsValues();
$apps = $this->getEnabledAppsValues();
$appsForGroups = array_filter($apps, function ($enabled) use ($group) {
return $this->checkAppForGroups($enabled, $group);
});
@ -303,7 +314,7 @@ class AppManager implements IAppManager {
}
public function getAppRestriction(string $appId): array {
$values = $this->getInstalledAppsValues();
$values = $this->getEnabledAppsValues();
if (!isset($values[$appId])) {
return [];
@ -329,9 +340,9 @@ class AppManager implements IAppManager {
if ($user === null) {
$user = $this->userSession->getUser();
}
$installedApps = $this->getInstalledAppsValues();
if (isset($installedApps[$appId])) {
return $this->checkAppForUser($installedApps[$appId], $user);
$enabledAppsValues = $this->getEnabledAppsValues();
if (isset($enabledAppsValues[$appId])) {
return $this->checkAppForUser($enabledAppsValues[$appId], $user);
} else {
return false;
}
@ -395,12 +406,14 @@ class AppManager implements IAppManager {
* Notice: This actually checks if the app is enabled and not only if it is installed.
*
* @param string $appId
* @param IGroup[]|String[] $groups
* @return bool
*/
public function isInstalled($appId) {
$installedApps = $this->getInstalledAppsValues();
return isset($installedApps[$appId]);
public function isInstalled($appId): bool {
return $this->isEnabledForAnyone($appId);
}
public function isEnabledForAnyone(string $appId): bool {
$enabledAppsValues = $this->getEnabledAppsValues();
return isset($enabledAppsValues[$appId]);
}
/**
@ -582,7 +595,7 @@ class AppManager implements IAppManager {
$this->overwriteNextcloudRequirement($appId);
}
$this->installedAppsCache[$appId] = 'yes';
$this->enabledAppsCache[$appId] = 'yes';
$this->getAppConfig()->setValue($appId, 'enabled', 'yes');
$this->dispatcher->dispatchTyped(new AppEnableEvent($appId));
$this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE, new ManagerEvent(
@ -636,7 +649,7 @@ class AppManager implements IAppManager {
: $group;
}, $groups);
$this->installedAppsCache[$appId] = json_encode($groupIds);
$this->enabledAppsCache[$appId] = json_encode($groupIds);
$this->getAppConfig()->setValue($appId, 'enabled', json_encode($groupIds));
$this->dispatcher->dispatchTyped(new AppEnableEvent($appId, $groupIds));
$this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE_FOR_GROUPS, new ManagerEvent(
@ -665,7 +678,7 @@ class AppManager implements IAppManager {
$this->autoDisabledApps[$appId] = $previousSetting;
}
unset($this->installedAppsCache[$appId]);
unset($this->enabledAppsCache[$appId]);
$this->getAppConfig()->setValue($appId, 'enabled', 'no');
// run uninstall steps
@ -726,7 +739,7 @@ class AppManager implements IAppManager {
*/
public function getAppsNeedingUpgrade($version) {
$appsToUpgrade = [];
$apps = $this->getInstalledApps();
$apps = $this->getEnabledApps();
foreach ($apps as $appId) {
$appInfo = $this->getAppInfo($appId);
$appDbVersion = $this->getAppConfig()->getValue($appId, 'installed_version');
@ -808,7 +821,7 @@ class AppManager implements IAppManager {
* @internal
*/
public function getIncompatibleApps(string $version): array {
$apps = $this->getInstalledApps();
$apps = $this->getEnabledApps();
$incompatibleApps = [];
foreach ($apps as $appId) {
$info = $this->getAppInfo($appId);

@ -88,7 +88,7 @@ class Application {
$this->writeMaintenanceModeInfo($input, $output);
} else {
$this->appManager->loadApps();
foreach ($this->appManager->getInstalledApps() as $app) {
foreach ($this->appManager->getEnabledApps() as $app) {
try {
$appPath = $this->appManager->getAppPath($app);
} catch (AppPathNotFoundException) {

@ -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
}
@ -97,7 +97,7 @@ class MetadataManager {
* @since 30.0.0
*/
public function getUnsupportedApps(array $metadata): array {
return array_values(array_diff($this->appManager->getInstalledApps(), array_keys($metadata['apps'])));
return array_values(array_diff($this->appManager->getEnabledApps(), array_keys($metadata['apps'])));
}
/**

@ -328,7 +328,7 @@ class NavigationManager implements INavigationManager {
$apps = $this->appManager->getEnabledAppsForUser($user);
$this->customAppOrder = json_decode($this->config->getUserValue($user->getUID(), 'core', 'apporder', '[]'), true, flags:JSON_THROW_ON_ERROR);
} else {
$apps = $this->appManager->getInstalledApps();
$apps = $this->appManager->getEnabledApps();
$this->customAppOrder = [];
}

@ -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'),

@ -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;
}

@ -78,7 +78,7 @@ class JSConfigHelper {
$apps_paths = [];
if ($this->currentUser === null) {
$apps = $this->appManager->getInstalledApps();
$apps = $this->appManager->getEnabledApps();
} else {
$apps = $this->appManager->getEnabledAppsForUser($this->currentUser);
}

@ -242,7 +242,7 @@ class Updater extends BasicEmitter {
$appManager = \OC::$server->getAppManager();
// upgrade appstore apps
$this->upgradeAppStoreApps($appManager->getInstalledApps());
$this->upgradeAppStoreApps($appManager->getEnabledApps());
$autoDisabledApps = $appManager->getAutoDisabledApps();
if (!empty($autoDisabledApps)) {
$this->upgradeAppStoreApps(array_keys($autoDisabledApps), $autoDisabledApps);

@ -185,7 +185,7 @@ class OC_App {
}
if (is_null($user)) {
$apps = $appManager->getInstalledApps();
$apps = $appManager->getEnabledApps();
} else {
$apps = $appManager->getEnabledAppsForUser($user);
}

@ -79,9 +79,17 @@ interface IAppManager {
* @param string $appId
* @return bool
* @since 8.0.0
* @deprecated 32.0.0 Use either {@see self::isEnabledForUser} or {@see self::isEnabledForAnyone}
*/
public function isInstalled($appId);
/**
* Check if an app is enabled in the instance, either for everyone or for specific groups
*
* @since 32.0.0
*/
public function isEnabledForAnyone(string $appId): bool;
/**
* Check if an app should be enabled by default
*
@ -178,9 +186,18 @@ interface IAppManager {
*
* @return string[]
* @since 8.1.0
* @deprecated 32.0.0 Use either {@see self::getEnabledApps} or {@see self::getEnabledAppsForUser}
*/
public function getInstalledApps();
/**
* List all apps enabled, either for everyone or for specific groups only
*
* @return list<string>
* @since 32.0.0
*/
public function getEnabledApps(): array;
/**
* Clear the cached list of apps when enabling/disabling an app
* @since 8.1.0

@ -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);
}

@ -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);

@ -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);

@ -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) {
@ -539,7 +539,7 @@ class AppManagerTest extends TestCase {
$this->assertTrue($this->manager->isEnabledForUser('test'));
}
public function testGetInstalledApps(): void {
public function testGetEnabledApps(): void {
$this->appConfig->setValue('test1', 'enabled', 'yes');
$this->appConfig->setValue('test2', 'enabled', 'no');
$this->appConfig->setValue('test3', 'enabled', '["foo"]');
@ -560,7 +560,7 @@ class AppManagerTest extends TestCase {
'viewer',
'workflowengine',
];
$this->assertEquals($apps, $this->manager->getInstalledApps());
$this->assertEquals($apps, $this->manager->getEnabledApps());
}
public function testGetAppsForUser(): void {

@ -718,7 +718,7 @@ class NavigationManagerTest extends TestCase {
'id' => 'settings',
]);
$this->appManager->method('getInstalledApps')->willReturn([]);
$this->appManager->method('getEnabledApps')->willReturn([]);
$user = $this->createMock(IUser::class);
$user->method('getUID')->willReturn('user1');
@ -743,7 +743,7 @@ class NavigationManagerTest extends TestCase {
}
public function testDefaultEntryUpdated(): void {
$this->appManager->method('getInstalledApps')->willReturn([]);
$this->appManager->method('getEnabledApps')->willReturn([]);
$user = $this->createMock(IUser::class);
$user->method('getUID')->willReturn('user1');

Loading…
Cancel
Save