fix: Replace OC_App::loadApp calls by IAppManager

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
pull/53893/head
Côme Chilliet 2025-07-10 10:17:42 +07:00
parent c7b83ef2e7
commit 7127ac4b43
No known key found for this signature in database
GPG Key ID: A3E2F658B28C760A
7 changed files with 32 additions and 19 deletions

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

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

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

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

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

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

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