Skip to content

Commit

Permalink
fix: Replace getInstalledApps calls with getEnabledApps
Browse files Browse the repository at this point in the history
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
  • Loading branch information
come-nc committed Feb 13, 2025
1 parent a368555 commit f758f56
Show file tree
Hide file tree
Showing 18 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion apps/dav/lib/AppInfo/PluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private function populate(): void {

$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)) {
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/tests/unit/AppInfo/PluginManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function test(): void {
$server = $this->createMock(ServerContainer::class);

$appManager = $this->createMock(AppManager::class);
$appManager->method('getInstalledApps')
$appManager->method('getEnabledApps')
->willReturn(['adavapp', 'adavapp2']);

$appInfo1 = [
Expand Down
2 changes: 1 addition & 1 deletion apps/files_trashbin/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function boot(IBootContext $context): void {
}

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'];
Expand Down
2 changes: 1 addition & 1 deletion apps/files_versions/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function boot(IBootContext $context): void {
}

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'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ protected function clearErrorNotifications() {
* 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) {
Expand Down
2 changes: 1 addition & 1 deletion apps/updatenotification/lib/Command/Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int


// Apps
$apps = $this->appManager->getInstalledApps();
$apps = $this->appManager->getEnabledApps();
foreach ($apps as $app) {
$update = $this->installer->isUpdateAvailable($app);
if ($update !== false) {
Expand Down
2 changes: 1 addition & 1 deletion apps/updatenotification/lib/Controller/APIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function getAppList(string $newVersion): DataResponse {
}

// 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public function testCheckAppUpdates(array $apps, array $isUpdateAvailable, array
]);

$this->appManager->expects($this->once())
->method('getInstalledApps')
->method('getEnabledApps')
->willReturn($apps);

$job->expects($this->exactly(\count($apps)))
Expand Down
2 changes: 1 addition & 1 deletion core/Command/App/Remove.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function completeOptionValues($optionName, CompletionContext $context): a
*/
public function completeArgumentValues($argumentName, CompletionContext $context): array {
if ($argumentName === 'app-id') {
return $this->manager->getInstalledApps();
return $this->manager->getEnabledApps();
}
return [];
}
Expand Down
2 changes: 1 addition & 1 deletion core/Command/Maintenance/Repair.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->repair->addStep($step);
}

$apps = $this->appManager->getInstalledApps();
$apps = $this->appManager->getEnabledApps();
foreach ($apps as $app) {
if (!$this->appManager->isEnabledForUser($app)) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function loadCommands(
$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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Migration/MetadataManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function getMigrationsAttributesFromReleaseMetadata(
* @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'])));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/private/NavigationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ private function init() {
$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 = [];
}

Expand Down
2 changes: 1 addition & 1 deletion lib/private/Template/JSConfigHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function getConfig(): string {
$apps_paths = [];

if ($this->currentUser === null) {
$apps = $this->appManager->getInstalledApps();
$apps = $this->appManager->getEnabledApps();
} else {
$apps = $this->appManager->getEnabledAppsForUser($this->currentUser);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private function doUpgrade(string $currentVersion, string $installedVersion): vo
$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);
Expand Down
2 changes: 1 addition & 1 deletion lib/private/legacy/OC_App.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public static function getEnabledApps(bool $forceRefresh = false, bool $all = fa
}

if (is_null($user)) {
$apps = $appManager->getInstalledApps();
$apps = $appManager->getEnabledApps();
} else {
$apps = $appManager->getEnabledAppsForUser($user);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/App/AppManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ public function testIsEnabledForUserLoggedIn(): void {
$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"]');
Expand All @@ -560,7 +560,7 @@ public function testGetInstalledApps(): void {
'viewer',
'workflowengine',
];
$this->assertEquals($apps, $this->manager->getInstalledApps());
$this->assertEquals($apps, $this->manager->getEnabledApps());
}

public function testGetAppsForUser(): void {
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/NavigationManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ public function testGetDefaultEntryIdForUser($defaultApps, $userDefaultApps, $us
'id' => 'settings',
]);

$this->appManager->method('getInstalledApps')->willReturn([]);
$this->appManager->method('getEnabledApps')->willReturn([]);

$user = $this->createMock(IUser::class);
$user->method('getUID')->willReturn('user1');
Expand All @@ -743,7 +743,7 @@ public function testGetDefaultEntryIdForUser($defaultApps, $userDefaultApps, $us
}

public function testDefaultEntryUpdated(): void {
$this->appManager->method('getInstalledApps')->willReturn([]);
$this->appManager->method('getEnabledApps')->willReturn([]);

$user = $this->createMock(IUser::class);
$user->method('getUID')->willReturn('user1');
Expand Down

0 comments on commit f758f56

Please sign in to comment.