Skip to content

Commit 5c53a18

Browse files
committed
refactor: migrate usage of OC_App to AppManager
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 043fd38 commit 5c53a18

10 files changed

Lines changed: 34 additions & 16 deletions

File tree

core/Command/App/Disable.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ public function completeOptionValues($optionName, CompletionContext $context): a
8080
#[\Override]
8181
public function completeArgumentValues($argumentName, CompletionContext $context): array {
8282
if ($argumentName === 'app-id') {
83-
return array_diff(\OC_App::getEnabledApps(true, true), $this->appManager->getAlwaysEnabledApps());
83+
$enabledApps = $this->appManager->getEnabledApps();
84+
$coreApps = $this->appManager->getAlwaysEnabledApps();
85+
return array_diff($enabledApps, $coreApps);
8486
}
8587
return [];
8688
}

core/Command/App/Enable.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ public function completeOptionValues($optionName, CompletionContext $context): a
148148
public function completeArgumentValues($argumentName, CompletionContext $context): array {
149149
if ($argumentName === 'app-id') {
150150
$allApps = $this->appManager->getAllAppsInAppsFolders();
151-
return array_diff($allApps, \OC_App::getEnabledApps(true, true));
151+
$enabledApps = $this->appManager->getEnabledApps();
152+
return array_diff($allApps, $enabledApps);
152153
}
153154
return [];
154155
}

core/Command/Config/ListConfigs.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use OC\Config\ConfigManager;
1111
use OC\Core\Command\Base;
1212
use OC\SystemConfig;
13+
use OCP\App\IAppManager;
1314
use OCP\IAppConfig;
1415
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
1516
use Symfony\Component\Console\Input\InputArgument;
@@ -24,6 +25,7 @@ public function __construct(
2425
protected SystemConfig $systemConfig,
2526
protected IAppConfig $appConfig,
2627
protected ConfigManager $configManager,
28+
protected IAppManager $appManager,
2729
) {
2830
parent::__construct();
2931
}
@@ -141,7 +143,7 @@ protected function getAppConfigs(string $app, bool $noSensitiveValues) {
141143
#[\Override]
142144
public function completeArgumentValues($argumentName, CompletionContext $context) {
143145
if ($argumentName === 'app') {
144-
return array_merge(['all', 'system'], \OC_App::getAllApps());
146+
return array_merge(['all', 'system'], $this->appManager->getAllAppsInAppsFolders());
145147
}
146148
return [];
147149
}

core/Command/Db/ExpectedSchema.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use OC\DB\MigrationService;
1515
use OC\DB\SchemaWrapper;
1616
use OC\Migration\NullOutput;
17+
use OCP\App\IAppManager;
1718
use Override;
1819
use Symfony\Component\Console\Input\InputArgument;
1920
use Symfony\Component\Console\Input\InputInterface;
@@ -23,6 +24,7 @@
2324
class ExpectedSchema extends Base {
2425
public function __construct(
2526
protected readonly Connection $connection,
27+
protected readonly IAppManager $appManager,
2628
) {
2729
parent::__construct();
2830
}
@@ -45,7 +47,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4547

4648
$this->applyMigrations('core', $schema);
4749

48-
$apps = \OC_App::getEnabledApps();
50+
$apps = $this->appManager->getEnabledApps();
4951
foreach ($apps as $app) {
5052
$this->applyMigrations($app, $schema);
5153
}

core/Command/Db/Migrations/ExecuteCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use OC\DB\Connection;
1111
use OC\DB\MigrationService;
1212
use OC\Migration\ConsoleOutput;
13+
use OCP\App\IAppManager;
1314
use OCP\IConfig;
1415
use Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionAwareInterface;
1516
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
@@ -22,6 +23,7 @@ class ExecuteCommand extends Command implements CompletionAwareInterface {
2223
public function __construct(
2324
private Connection $connection,
2425
private IConfig $config,
26+
private IAppManager $appManager,
2527
) {
2628
parent::__construct();
2729
}
@@ -81,8 +83,8 @@ public function completeOptionValues($optionName, CompletionContext $context) {
8183
#[\Override]
8284
public function completeArgumentValues($argumentName, CompletionContext $context) {
8385
if ($argumentName === 'app') {
84-
$allApps = \OC_App::getAllApps();
85-
return array_diff($allApps, \OC_App::getEnabledApps(true, true));
86+
$allApps = $this->appManager->getAllAppsInAppsFolders();
87+
return array_diff($allApps, $this->appManager->getEnabledApps());
8688
}
8789

8890
if ($argumentName === 'version') {

core/Command/Db/Migrations/GenerateCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ public function completeOptionValues($optionName, CompletionContext $context) {
164164
public function completeArgumentValues($argumentName, CompletionContext $context) {
165165
if ($argumentName === 'app') {
166166
$allApps = $this->appManager->getAllAppsInAppsFolders();
167-
return array_diff($allApps, \OC_App::getEnabledApps(true, true));
167+
$enabledApps = $this->appManager->getEnabledApps();
168+
return array_diff($allApps, $enabledApps);
168169
}
169170

170171
if ($argumentName === 'version') {

core/Command/Db/Migrations/MigrateCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use OC\DB\Connection;
1111
use OC\DB\MigrationService;
1212
use OC\Migration\ConsoleOutput;
13+
use OCP\App\IAppManager;
1314
use Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionAwareInterface;
1415
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
1516
use Symfony\Component\Console\Command\Command;
@@ -20,6 +21,7 @@
2021
class MigrateCommand extends Command implements CompletionAwareInterface {
2122
public function __construct(
2223
private Connection $connection,
24+
private IAppManager $appManager,
2325
) {
2426
parent::__construct();
2527
}
@@ -63,8 +65,8 @@ public function completeOptionValues($optionName, CompletionContext $context) {
6365
#[\Override]
6466
public function completeArgumentValues($argumentName, CompletionContext $context) {
6567
if ($argumentName === 'app') {
66-
$allApps = \OC_App::getAllApps();
67-
return array_diff($allApps, \OC_App::getEnabledApps(true, true));
68+
$allApps = $this->appManager->getAllAppsInAppsFolders();
69+
return array_diff($allApps, $this->appManager->getEnabledApps());
6870
}
6971

7072
if ($argumentName === 'version') {

core/Command/Db/Migrations/StatusCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use OC\DB\Connection;
1111
use OC\DB\MigrationService;
1212
use OC\Migration\ConsoleOutput;
13+
use OCP\App\IAppManager;
1314
use Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionAwareInterface;
1415
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext;
1516
use Symfony\Component\Console\Command\Command;
@@ -20,6 +21,7 @@
2021
class StatusCommand extends Command implements CompletionAwareInterface {
2122
public function __construct(
2223
private Connection $connection,
24+
private IAppManager $appManager,
2325
) {
2426
parent::__construct();
2527
}
@@ -69,8 +71,8 @@ public function completeOptionValues($optionName, CompletionContext $context) {
6971
#[\Override]
7072
public function completeArgumentValues($argumentName, CompletionContext $context) {
7173
if ($argumentName === 'app') {
72-
$allApps = \OC_App::getAllApps();
73-
return array_diff($allApps, \OC_App::getEnabledApps(true, true));
74+
$allApps = $this->appManager->getAllAppsInAppsFolders();
75+
return array_diff($allApps, $this->appManager->getEnabledApps());
7476
}
7577
return [];
7678
}

lib/private/AppFramework/Bootstrap/Coordinator.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,12 @@ public function __construct(
4646
}
4747

4848
public function runInitialRegistration(): void {
49-
$apps = OC_App::getEnabledApps();
50-
if (!empty($apps)) {
51-
// make sure to also register the core app
49+
try {
50+
$apps = $this->appManager->getEnabledApps();
5251
$apps = ['core', ...$apps];
52+
} catch (\Exception) {
53+
// not yet installed
54+
$apps = [];
5355
}
5456

5557
$this->registerApps($apps);

lib/private/legacy/OC_User.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use OC\User\Database;
1111
use OC\User\DisabledUserException;
1212
use OC\User\Session;
13+
use OCP\App\IAppManager;
1314
use OCP\Authentication\Exceptions\InvalidTokenException;
1415
use OCP\Authentication\Exceptions\WipeTokenException;
1516
use OCP\Authentication\IApacheBackend;
@@ -108,7 +109,8 @@ public static function clearBackends() {
108109
* @suppress PhanDeprecatedFunction
109110
*/
110111
public static function setupBackends() {
111-
OC_App::loadApps(['prelogin']);
112+
Server::get(IAppManager::class)->loadApps(['prelogin']);
113+
112114
$backends = Server::get(SystemConfig::class)->getValue('user_backends', []);
113115
if (isset($backends['default']) && !$backends['default']) {
114116
// clear default backends
@@ -231,7 +233,7 @@ public static function loginWithApache(IApacheBackend $backend): bool {
231233
public static function handleApacheAuth(): ?bool {
232234
$backend = self::findFirstActiveUsedBackend();
233235
if ($backend) {
234-
OC_App::loadApps();
236+
Server::get(IAppManager::class)->loadApps();
235237

236238
//setup extra user backends
237239
self::setupBackends();

0 commit comments

Comments
 (0)