aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKate <26026535+provokateurin@users.noreply.github.com>2025-07-10 15:06:05 +0200
committerGitHub <noreply@github.com>2025-07-10 15:06:05 +0200
commit034246a1a9d7a9815159f43d548ce2f6c5ebc3cb (patch)
tree6556fa300b9a72f76a72050025f71f02e144aa53
parentc0b31d1e2d2d373205181904b38f88e47d4ee8ab (diff)
parentda20bbb44d01eb810a6b8a1f6f10e40c3f3eb488 (diff)
downloadnextcloud-server-034246a1a9d7a9815159f43d548ce2f6c5ebc3cb.tar.gz
nextcloud-server-034246a1a9d7a9815159f43d548ce2f6c5ebc3cb.zip
Merge pull request #53893 from nextcloud/fix/cleanup-loadapp-calls
-rw-r--r--apps/dav/lib/AppInfo/Application.php3
-rw-r--r--apps/dav/tests/unit/bootstrap.php13
-rw-r--r--apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php4
-rw-r--r--apps/user_status/tests/bootstrap.php11
-rw-r--r--build/psalm-baseline.xml11
-rw-r--r--core/Command/Db/ConvertType.php8
-rw-r--r--lib/private/Files/SetupManager.php5
-rw-r--r--lib/private/Files/SetupManagerFactory.php3
-rw-r--r--ocs/v1.php25
-rw-r--r--tests/bootstrap.php9
-rw-r--r--tests/lib/Traits/EncryptionTrait.php3
11 files changed, 54 insertions, 41 deletions
diff --git a/apps/dav/lib/AppInfo/Application.php b/apps/dav/lib/AppInfo/Application.php
index 9d5921a1e83..9807b585080 100644
--- a/apps/dav/lib/AppInfo/Application.php
+++ b/apps/dav/lib/AppInfo/Application.php
@@ -64,6 +64,7 @@ use OCA\DAV\SetupChecks\WebdavEndpoint;
use OCA\DAV\UserMigration\CalendarMigrator;
use OCA\DAV\UserMigration\ContactsMigrator;
use OCP\Accounts\UserUpdatedEvent;
+use OCP\App\IAppManager;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
@@ -217,7 +218,7 @@ class Application extends App implements IBootstrap {
public function boot(IBootContext $context): void {
// Load all dav apps
- \OC_App::loadApps(['dav']);
+ $context->getServerContainer()->get(IAppManager::class)->loadApps(['dav']);
$context->injectFn($this->registerContactsManager(...));
$context->injectFn($this->registerCalendarManager(...));
diff --git a/apps/dav/tests/unit/bootstrap.php b/apps/dav/tests/unit/bootstrap.php
index 886a7f0b859..ee76bb6677b 100644
--- a/apps/dav/tests/unit/bootstrap.php
+++ b/apps/dav/tests/unit/bootstrap.php
@@ -1,18 +1,21 @@
<?php
+declare(strict_types=1);
+
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
+
+use OCP\App\IAppManager;
+use OCP\Server;
+
if (!defined('PHPUNIT_RUN')) {
define('PHPUNIT_RUN', 1);
}
require_once __DIR__ . '/../../../../lib/base.php';
+require_once __DIR__ . '/../../../../tests/autoload.php';
-\OC::$composerAutoloader->addPsr4('Test\\', OC::$SERVERROOT . '/tests/lib/', true);
-
-\OC_App::loadApp('dav');
-
-OC_Hook::clear();
+Server::get(IAppManager::class)->loadApp('dav');
diff --git a/apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php b/apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php
index 78f6df9d7bc..3eec3df675a 100644
--- a/apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php
+++ b/apps/user_ldap/tests/Integration/ExceptionOnLostConnection.php
@@ -9,6 +9,8 @@ namespace OCA\User_LDAP\Tests\Integration;
use OC\ServerNotAvailableException;
use OCA\User_LDAP\LDAP;
+use OCP\App\IAppManager;
+use OCP\Server;
/**
* Class ExceptionOnLostConnection
@@ -63,7 +65,7 @@ class ExceptionOnLostConnection {
*/
public function setUp(): void {
require_once __DIR__ . '/../../../../lib/base.php';
- \OC_App::loadApps(['user_ldap']);
+ Server::get(IAppManager::class)->loadApps(['user_ldap']);
$ch = $this->getCurl();
$proxyInfoJson = curl_exec($ch);
diff --git a/apps/user_status/tests/bootstrap.php b/apps/user_status/tests/bootstrap.php
index c24f86c7cbe..c98daca1dfc 100644
--- a/apps/user_status/tests/bootstrap.php
+++ b/apps/user_status/tests/bootstrap.php
@@ -6,14 +6,15 @@ declare(strict_types=1);
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
+
+use OCP\App\IAppManager;
+use OCP\Server;
+
if (!defined('PHPUNIT_RUN')) {
define('PHPUNIT_RUN', 1);
}
require_once __DIR__ . '/../../../lib/base.php';
+require_once __DIR__ . '/../../../tests/autoload.php';
-\OC::$composerAutoloader->addPsr4('Test\\', OC::$SERVERROOT . '/tests/lib/', true);
-
-\OC_App::loadApp('user_status');
-
-OC_Hook::clear();
+Server::get(IAppManager::class)->loadApp('user_status');
diff --git a/build/psalm-baseline.xml b/build/psalm-baseline.xml
index 21007bec0bf..2e29009afaf 100644
--- a/build/psalm-baseline.xml
+++ b/build/psalm-baseline.xml
@@ -209,7 +209,6 @@
<code><![CDATA[IAppContainer]]></code>
</DeprecatedInterface>
<DeprecatedMethod>
- <code><![CDATA[\OC_App::loadApps(['dav'])]]></code>
<code><![CDATA[getServer]]></code>
<code><![CDATA[getServer]]></code>
<code><![CDATA[getURLGenerator]]></code>
@@ -2925,8 +2924,6 @@
</file>
<file src="core/Command/Db/ConvertType.php">
<DeprecatedMethod>
- <code><![CDATA[\OC_App::getAllApps()]]></code>
- <code><![CDATA[\OC_App::loadApp($app)]]></code>
<code><![CDATA[execute]]></code>
<code><![CDATA[getName]]></code>
<code><![CDATA[getPrimaryKeyColumns]]></code>
@@ -4473,14 +4470,6 @@
<code><![CDATA[getRequest]]></code>
</DeprecatedMethod>
</file>
- <file src="ocs/v1.php">
- <DeprecatedMethod>
- <code><![CDATA[OC_App::loadApps()]]></code>
- <code><![CDATA[OC_App::loadApps(['authentication'])]]></code>
- <code><![CDATA[OC_App::loadApps(['extended_authentication'])]]></code>
- <code><![CDATA[OC_App::loadApps(['session'])]]></code>
- </DeprecatedMethod>
- </file>
<file src="public.php">
<DeprecatedMethod>
<code><![CDATA[getAppValue]]></code>
diff --git a/core/Command/Db/ConvertType.php b/core/Command/Db/ConvertType.php
index bca41407f68..0067bec4d9e 100644
--- a/core/Command/Db/ConvertType.php
+++ b/core/Command/Db/ConvertType.php
@@ -14,6 +14,7 @@ use OC\DB\Connection;
use OC\DB\ConnectionFactory;
use OC\DB\MigrationService;
use OC\DB\PgSqlTools;
+use OCP\App\IAppManager;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\DB\Types;
use OCP\IConfig;
@@ -38,6 +39,7 @@ class ConvertType extends Command implements CompletionAwareInterface {
public function __construct(
protected IConfig $config,
protected ConnectionFactory $connectionFactory,
+ protected IAppManager $appManager,
) {
parent::__construct();
}
@@ -208,11 +210,13 @@ class ConvertType extends Command implements CompletionAwareInterface {
$toMS->migrate($currentMigration);
}
- $apps = $input->getOption('all-apps') ? \OC_App::getAllApps() : \OC_App::getEnabledApps();
+ $apps = $input->getOption('all-apps')
+ ? $this->appManager->getAllAppsInAppsFolders()
+ : $this->appManager->getEnabledApps();
foreach ($apps as $app) {
$output->writeln('<info> - ' . $app . '</info>');
// Make sure autoloading works...
- \OC_App::loadApp($app);
+ $this->appManager->loadApp($app);
$fromMS = new MigrationService($app, $fromDB);
$currentMigration = $fromMS->getMigration('current');
if ($currentMigration !== '0') {
diff --git a/lib/private/Files/SetupManager.php b/lib/private/Files/SetupManager.php
index d6260c38fb0..37ecd5779e6 100644
--- a/lib/private/Files/SetupManager.php
+++ b/lib/private/Files/SetupManager.php
@@ -21,12 +21,12 @@ use OC\Files\Storage\Wrapper\Quota;
use OC\Lockdown\Filesystem\NullStorage;
use OC\Share\Share;
use OC\Share20\ShareDisableChecker;
-use OC_App;
use OC_Hook;
use OCA\Files_External\Config\ExternalMountPoint;
use OCA\Files_Sharing\External\Mount;
use OCA\Files_Sharing\ISharedMountPoint;
use OCA\Files_Sharing\SharedMount;
+use OCP\App\IAppManager;
use OCP\Constants;
use OCP\Diagnostics\IEventLogger;
use OCP\EventDispatcher\IEventDispatcher;
@@ -81,6 +81,7 @@ class SetupManager {
private LoggerInterface $logger,
private IConfig $config,
private ShareDisableChecker $shareDisableChecker,
+ private IAppManager $appManager,
) {
$this->cache = $cacheFactory->createDistributed('setupmanager::');
$this->listeningForProviders = false;
@@ -104,7 +105,7 @@ class SetupManager {
$this->setupBuiltinWrappersDone = true;
// load all filesystem apps before, so no setup-hook gets lost
- OC_App::loadApps(['filesystem']);
+ $this->appManager->loadApps(['filesystem']);
$prevLogging = Filesystem::logWarningWhenAddingStorageWrapper(false);
Filesystem::addStorageWrapper('mount_options', function ($mountPoint, IStorage $storage, IMountPoint $mount) {
diff --git a/lib/private/Files/SetupManagerFactory.php b/lib/private/Files/SetupManagerFactory.php
index 6ae38c6fdbc..d2fe978fa9e 100644
--- a/lib/private/Files/SetupManagerFactory.php
+++ b/lib/private/Files/SetupManagerFactory.php
@@ -9,6 +9,7 @@ declare(strict_types=1);
namespace OC\Files;
use OC\Share20\ShareDisableChecker;
+use OCP\App\IAppManager;
use OCP\Diagnostics\IEventLogger;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Config\IMountProviderCollection;
@@ -36,6 +37,7 @@ class SetupManagerFactory {
private LoggerInterface $logger,
private IConfig $config,
private ShareDisableChecker $shareDisableChecker,
+ private IAppManager $appManager,
) {
$this->setupManager = null;
}
@@ -55,6 +57,7 @@ class SetupManagerFactory {
$this->logger,
$this->config,
$this->shareDisableChecker,
+ $this->appManager,
);
}
return $this->setupManager;
diff --git a/ocs/v1.php b/ocs/v1.php
index 97032e63740..e12cd6ddc11 100644
--- a/ocs/v1.php
+++ b/ocs/v1.php
@@ -2,14 +2,6 @@
declare(strict_types=1);
-use OC\Route\Router;
-use OC\SystemConfig;
-use OC\User\LoginException;
-use OCP\IConfig;
-use OCP\IRequest;
-use OCP\IUserSession;
-use OCP\Server;
-
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -20,9 +12,17 @@ require_once __DIR__ . '/../lib/versioncheck.php';
require_once __DIR__ . '/../lib/base.php';
use OC\OCS\ApiHelper;
+use OC\Route\Router;
+use OC\SystemConfig;
+use OC\User\LoginException;
+use OCP\App\IAppManager;
use OCP\AppFramework\Http;
use OCP\AppFramework\OCSController;
+use OCP\IConfig;
+use OCP\IRequest;
+use OCP\IUserSession;
use OCP\Security\Bruteforce\MaxDelayReached;
+use OCP\Server;
use OCP\Util;
use Psr\Log\LoggerInterface;
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
@@ -41,14 +41,15 @@ if (Util::needUpgrade()
* Try the appframework routes
*/
try {
- OC_App::loadApps(['session']);
- OC_App::loadApps(['authentication']);
- OC_App::loadApps(['extended_authentication']);
+ $appManager = Server::get(IAppManager::class);
+ $appManager->loadApps(['session']);
+ $appManager->loadApps(['authentication']);
+ $appManager->loadApps(['extended_authentication']);
// load all apps to get all api routes properly setup
// FIXME: this should ideally appear after handleLogin but will cause
// side effects in existing apps
- OC_App::loadApps();
+ $appManager->loadApps();
$request = Server::get(IRequest::class);
$request->throwDecodingExceptionIfAny();
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 3e50e6aef62..81bb930de65 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -1,10 +1,16 @@
<?php
+declare(strict_types=1);
+
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
+
+use OCP\App\IAppManager;
+use OCP\Server;
+
define('PHPUNIT_RUN', 1);
$configDir = getenv('CONFIG_DIR');
@@ -18,11 +24,12 @@ require_once __DIR__ . '/autoload.php';
\OC::$composerAutoloader->addPsr4('Tests\\', OC::$SERVERROOT . '/tests/', true);
// load all apps
+$appManager = Server::get(IAppManager::class);
foreach (new \DirectoryIterator(__DIR__ . '/../apps/') as $file) {
if ($file->isDot()) {
continue;
}
- \OC_App::loadApp($file->getFilename());
+ $appManager->loadApp($file->getFilename());
}
OC_Hook::clear();
diff --git a/tests/lib/Traits/EncryptionTrait.php b/tests/lib/Traits/EncryptionTrait.php
index 50c20befc4d..44d5dcab8cb 100644
--- a/tests/lib/Traits/EncryptionTrait.php
+++ b/tests/lib/Traits/EncryptionTrait.php
@@ -15,6 +15,7 @@ use OCA\Encryption\AppInfo\Application;
use OCA\Encryption\Crypto\Encryption;
use OCA\Encryption\KeyManager;
use OCA\Encryption\Users\Setup;
+use OCP\App\IAppManager;
use OCP\Encryption\IManager;
use OCP\IConfig;
use OCP\IUserManager;
@@ -102,7 +103,7 @@ trait EncryptionTrait {
$this->userManager = Server::get(IUserManager::class);
$this->setupManager = Server::get(SetupManager::class);
- \OC_App::loadApp('encryption');
+ Server::get(IAppManager::class)->loadApp('encryption');
$this->encryptionApp = new Application([], $isReady);