diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2023-06-06 11:09:24 +0200 |
---|---|---|
committer | Christoph Wurst <ChristophWurst@users.noreply.github.com> | 2023-07-06 15:21:22 +0200 |
commit | 14719110b9c795a95b23c2278168b9d6123b1a62 (patch) | |
tree | 9919ba8c849e3397e23e46ad9f1fdc3f951d3a7f | |
parent | 5538a40029da60547798ae6f9e11179c4ee4a642 (diff) | |
download | nextcloud-server-14719110b9c795a95b23c2278168b9d6123b1a62.tar.gz nextcloud-server-14719110b9c795a95b23c2278168b9d6123b1a62.zip |
chore: Replace \OC::$server->query with \OCP\Server::get in /lib
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
-rw-r--r-- | lib/private/Activity/Manager.php | 6 | ||||
-rw-r--r-- | lib/private/Authentication/TwoFactorAuth/ProviderLoader.php | 4 | ||||
-rw-r--r-- | lib/private/Collaboration/Resources/Listener.php | 6 | ||||
-rw-r--r-- | lib/private/Console/Application.php | 6 | ||||
-rw-r--r-- | lib/private/DB/MigrationService.php | 2 | ||||
-rw-r--r-- | lib/private/Files/Cache/Cache.php | 2 | ||||
-rw-r--r-- | lib/private/Files/Node/Folder.php | 2 | ||||
-rw-r--r-- | lib/private/Preview/WatcherConnector.php | 2 | ||||
-rw-r--r-- | lib/private/Repair.php | 6 | ||||
-rw-r--r-- | lib/private/Search/Provider/File.php | 4 | ||||
-rw-r--r-- | lib/private/Session/Internal.php | 2 | ||||
-rw-r--r-- | lib/private/Setup.php | 10 | ||||
-rw-r--r-- | lib/private/TemplateLayout.php | 6 | ||||
-rw-r--r-- | lib/private/User/Database.php | 2 | ||||
-rw-r--r-- | lib/private/User/User.php | 6 | ||||
-rw-r--r-- | lib/private/legacy/OC_App.php | 12 | ||||
-rw-r--r-- | lib/private/legacy/OC_Files.php | 2 | ||||
-rw-r--r-- | lib/private/legacy/OC_Template.php | 2 | ||||
-rw-r--r-- | lib/private/legacy/template/functions.php | 2 | ||||
-rw-r--r-- | lib/public/AppFramework/Http/Response.php | 2 | ||||
-rw-r--r-- | lib/public/Util.php | 5 |
21 files changed, 46 insertions, 45 deletions
diff --git a/lib/private/Activity/Manager.php b/lib/private/Activity/Manager.php index 00b2ba434a8..a7d24510d53 100644 --- a/lib/private/Activity/Manager.php +++ b/lib/private/Activity/Manager.php @@ -192,7 +192,7 @@ class Manager implements IManager { public function getFilters(): array { foreach ($this->filterClasses as $class => $false) { /** @var IFilter $filter */ - $filter = \OC::$server->query($class); + $filter = \OCP\Server::get($class); if (!$filter instanceof IFilter) { throw new \InvalidArgumentException('Invalid activity filter registered'); @@ -242,7 +242,7 @@ class Manager implements IManager { public function getProviders(): array { foreach ($this->providerClasses as $class => $false) { /** @var IProvider $provider */ - $provider = \OC::$server->query($class); + $provider = \OCP\Server::get($class); if (!$provider instanceof IProvider) { throw new \InvalidArgumentException('Invalid activity provider registered'); @@ -276,7 +276,7 @@ class Manager implements IManager { public function getSettings(): array { foreach ($this->settingsClasses as $class => $false) { /** @var ISetting $setting */ - $setting = \OC::$server->query($class); + $setting = \OCP\Server::get($class); if ($setting instanceof ISetting) { if (!$setting instanceof ActivitySettings) { diff --git a/lib/private/Authentication/TwoFactorAuth/ProviderLoader.php b/lib/private/Authentication/TwoFactorAuth/ProviderLoader.php index 25cdc387f61..efd92f8ba30 100644 --- a/lib/private/Authentication/TwoFactorAuth/ProviderLoader.php +++ b/lib/private/Authentication/TwoFactorAuth/ProviderLoader.php @@ -66,7 +66,7 @@ class ProviderLoader { foreach ($providerClasses as $class) { try { $this->loadTwoFactorApp($appId); - $provider = OC::$server->query($class); + $provider = \OCP\Server::get($class); $providers[$provider->getId()] = $provider; } catch (QueryException $exc) { // Provider class can not be resolved @@ -80,7 +80,7 @@ class ProviderLoader { foreach ($registeredProviders as $provider) { try { $this->loadTwoFactorApp($provider->getAppId()); - $provider = OC::$server->query($provider->getService()); + $provider = \OCP\Server::get($provider->getService()); $providers[$provider->getId()] = $provider; } catch (QueryException $exc) { // Provider class can not be resolved diff --git a/lib/private/Collaboration/Resources/Listener.php b/lib/private/Collaboration/Resources/Listener.php index b9f1e72cbfa..d3b2f012a29 100644 --- a/lib/private/Collaboration/Resources/Listener.php +++ b/lib/private/Collaboration/Resources/Listener.php @@ -40,7 +40,7 @@ class Listener { /** @var IUser $user */ $user = $event->getArgument('user'); /** @var IManager $resourceManager */ - $resourceManager = \OC::$server->query(IManager::class); + $resourceManager = \OCP\Server::get(IManager::class); $resourceManager->invalidateAccessCacheForUser($user); }; @@ -51,7 +51,7 @@ class Listener { /** @var IUser $user */ $user = $event->getSubject(); /** @var IManager $resourceManager */ - $resourceManager = \OC::$server->query(IManager::class); + $resourceManager = \OCP\Server::get(IManager::class); $resourceManager->invalidateAccessCacheForUser($user); }); @@ -60,7 +60,7 @@ class Listener { /** @var IGroup $group */ $group = $event->getSubject(); /** @var IManager $resourceManager */ - $resourceManager = \OC::$server->query(IManager::class); + $resourceManager = \OCP\Server::get(IManager::class); foreach ($group->getUsers() as $user) { $resourceManager->invalidateAccessCacheForUser($user); diff --git a/lib/private/Console/Application.php b/lib/private/Console/Application.php index 11515f26866..113f0507ef5 100644 --- a/lib/private/Console/Application.php +++ b/lib/private/Console/Application.php @@ -33,12 +33,12 @@ namespace OC\Console; use OC\MemoryInfo; use OC\NeedsUpdateException; use OC_App; -use OCP\AppFramework\QueryException; use OCP\App\IAppManager; use OCP\Console\ConsoleEvent; use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; use OCP\IRequest; +use Psr\Container\ContainerExceptionInterface; use Psr\Log\LoggerInterface; use Symfony\Component\Console\Application as SymfonyApplication; use Symfony\Component\Console\Input\InputInterface; @@ -216,8 +216,8 @@ class Application { private function loadCommandsFromInfoXml($commands) { foreach ($commands as $command) { try { - $c = \OC::$server->query($command); - } catch (QueryException $e) { + $c = \OCP\Server::get($command); + } catch (ContainerExceptionInterface $e) { if (class_exists($command)) { try { $c = new $command(); diff --git a/lib/private/DB/MigrationService.php b/lib/private/DB/MigrationService.php index 7993730b230..3afe2f689f9 100644 --- a/lib/private/DB/MigrationService.php +++ b/lib/private/DB/MigrationService.php @@ -487,7 +487,7 @@ class MigrationService { protected function createInstance($version) { $class = $this->getClass($version); try { - $s = \OC::$server->query($class); + $s = \OCP\Server::get($class); if (!$s instanceof IMigrationStep) { throw new \InvalidArgumentException('Not a valid migration'); diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index 5aa05683631..4770e168bfb 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -125,7 +125,7 @@ class Cache implements ICache { $this->mimetypeLoader = \OC::$server->getMimeTypeLoader(); $this->connection = \OC::$server->getDatabaseConnection(); $this->eventDispatcher = \OC::$server->get(IEventDispatcher::class); - $this->querySearchHelper = \OC::$server->query(QuerySearchHelper::class); + $this->querySearchHelper = \OCP\Server::get(QuerySearchHelper::class); } protected function getQueryBuilder() { diff --git a/lib/private/Files/Node/Folder.php b/lib/private/Files/Node/Folder.php index 3622f336047..ccd10da9d0c 100644 --- a/lib/private/Files/Node/Folder.php +++ b/lib/private/Files/Node/Folder.php @@ -204,7 +204,7 @@ class Folder extends Node implements \OCP\Files\Folder { $user = null; } else { /** @var IUserManager $userManager */ - $userManager = \OC::$server->query(IUserManager::class); + $userManager = \OCP\Server::get(IUserManager::class); $user = $userManager->get($uid); } return new SearchQuery($operator, $limit, $offset, [], $user); diff --git a/lib/private/Preview/WatcherConnector.php b/lib/private/Preview/WatcherConnector.php index d0eafed42c1..ffbdf825211 100644 --- a/lib/private/Preview/WatcherConnector.php +++ b/lib/private/Preview/WatcherConnector.php @@ -52,7 +52,7 @@ class WatcherConnector { * @return Watcher */ private function getWatcher(): Watcher { - return \OC::$server->query(Watcher::class); + return \OCP\Server::get(Watcher::class); } public function connectWatcher() { diff --git a/lib/private/Repair.php b/lib/private/Repair.php index 330fa241b1e..9c6a6cd00f2 100644 --- a/lib/private/Repair.php +++ b/lib/private/Repair.php @@ -191,14 +191,14 @@ class Repair implements IOutput { new FixMountStorages(\OC::$server->getDatabaseConnection()), new UpdateLanguageCodes(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig()), new AddLogRotateJob(\OC::$server->getJobList()), - new ClearFrontendCaches(\OC::$server->getMemCacheFactory(), \OC::$server->query(JSCombiner::class)), + new ClearFrontendCaches(\OC::$server->getMemCacheFactory(), \OCP\Server::get(JSCombiner::class)), \OCP\Server::get(ClearGeneratedAvatarCache::class), new AddPreviewBackgroundCleanupJob(\OC::$server->getJobList()), new AddCleanupUpdaterBackupsJob(\OC::$server->getJobList()), new CleanupCardDAVPhotoCache(\OC::$server->getConfig(), \OC::$server->getAppDataDir('dav-photocache'), \OC::$server->get(LoggerInterface::class)), new AddClenupLoginFlowV2BackgroundJob(\OC::$server->getJobList()), - new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), \OC::$server->getNotificationManager(), \OC::$server->query(ITimeFactory::class)), - new ClearCollectionsAccessCache(\OC::$server->getConfig(), \OC::$server->query(IManager::class)), + new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), \OC::$server->getNotificationManager(), \OCP\Server::get(ITimeFactory::class)), + new ClearCollectionsAccessCache(\OC::$server->getConfig(), \OCP\Server::get(IManager::class)), \OCP\Server::get(ResetGeneratedAvatarFlag::class), \OCP\Server::get(EncryptionLegacyCipher::class), \OCP\Server::get(EncryptionMigration::class), diff --git a/lib/private/Search/Provider/File.php b/lib/private/Search/Provider/File.php index 7046fea33d2..5ec0132cc03 100644 --- a/lib/private/Search/Provider/File.php +++ b/lib/private/Search/Provider/File.php @@ -53,9 +53,9 @@ class File extends PagedProvider { */ public function search($query, int $limit = null, int $offset = null) { /** @var IRootFolder $rootFolder */ - $rootFolder = \OC::$server->query(IRootFolder::class); + $rootFolder = \OCP\Server::get(IRootFolder::class); /** @var IUserSession $userSession */ - $userSession = \OC::$server->query(IUserSession::class); + $userSession = \OCP\Server::get(IUserSession::class); $user = $userSession->getUser(); if (!$user) { return []; diff --git a/lib/private/Session/Internal.php b/lib/private/Session/Internal.php index e0f92c2e887..e8e2a4f2d8e 100644 --- a/lib/private/Session/Internal.php +++ b/lib/private/Session/Internal.php @@ -149,7 +149,7 @@ class Internal extends Session { $newId = $this->getId(); /** @var IProvider $tokenProvider */ - $tokenProvider = \OC::$server->query(IProvider::class); + $tokenProvider = \OCP\Server::get(IProvider::class); try { $tokenProvider->renewSessionToken($oldId, $newId); diff --git a/lib/private/Setup.php b/lib/private/Setup.php index 3a2e7614dd9..d847125cc79 100644 --- a/lib/private/Setup.php +++ b/lib/private/Setup.php @@ -424,20 +424,20 @@ class Setup { unlink(\OC::$configDir.'/CAN_INSTALL'); } - $bootstrapCoordinator = \OC::$server->query(\OC\AppFramework\Bootstrap\Coordinator::class); + $bootstrapCoordinator = \OCP\Server::get(\OC\AppFramework\Bootstrap\Coordinator::class); $bootstrapCoordinator->runInitialRegistration(); // Create a session token for the newly created user // The token provider requires a working db, so it's not injected on setup /* @var $userSession User\Session */ $userSession = \OC::$server->getUserSession(); - $provider = \OC::$server->query(PublicKeyTokenProvider::class); + $provider = \OCP\Server::get(PublicKeyTokenProvider::class); $userSession->setTokenProvider($provider); $userSession->login($username, $password); $userSession->createSessionToken($request, $userSession->getUser()->getUID(), $username, $password); $session = $userSession->getSession(); - $session->set('last-password-confirm', \OC::$server->query(ITimeFactory::class)->getTime()); + $session->set('last-password-confirm', \OCP\Server::get(ITimeFactory::class)->getTime()); // Set email for admin if (!empty($options['adminemail'])) { @@ -506,10 +506,10 @@ class Setup { $config, \OC::$server->get(IniGetWrapper::class), \OC::$server->getL10N('lib'), - \OC::$server->query(Defaults::class), + \OCP\Server::get(Defaults::class), \OC::$server->get(LoggerInterface::class), \OC::$server->getSecureRandom(), - \OC::$server->query(Installer::class) + \OCP\Server::get(Installer::class) ); $htaccessContent = file_get_contents($setupHelper->pathToHtaccess()); diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index 5c6488cbc0f..658a85152bf 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -190,7 +190,7 @@ class TemplateLayout extends \OC_Template { $this->assign('bodyid', 'body-public'); /** @var IRegistry $subscription */ - $subscription = \OC::$server->query(IRegistry::class); + $subscription = \OCP\Server::get(IRegistry::class); $showSimpleSignup = $this->config->getSystemValueBool('simpleSignUpLink.shown', true); if ($showSimpleSignup && $subscription->delegateHasValidSubscription()) { $showSimpleSignup = false; @@ -226,7 +226,7 @@ class TemplateLayout extends \OC_Template { // see https://github.com/nextcloud/server/pull/22636 for details $jsConfigHelper = new JSConfigHelper( \OC::$server->getL10N('lib'), - \OC::$server->query(Defaults::class), + \OCP\Server::get(Defaults::class), \OC::$server->getAppManager(), \OC::$server->getSession(), \OC::$server->getUserSession()->getUser(), @@ -235,7 +235,7 @@ class TemplateLayout extends \OC_Template { \OC::$server->get(IniGetWrapper::class), \OC::$server->getURLGenerator(), \OC::$server->getCapabilitiesManager(), - \OC::$server->query(IInitialStateService::class) + \OCP\Server::get(IInitialStateService::class) ); $config = $jsConfigHelper->getConfig(); if (\OC::$server->getContentSecurityPolicyNonceManager()->browserSupportsCspV3()) { diff --git a/lib/private/User/Database.php b/lib/private/User/Database.php index 615c392395e..9ef1bc67a58 100644 --- a/lib/private/User/Database.php +++ b/lib/private/User/Database.php @@ -97,7 +97,7 @@ class Database extends ABackend implements public function __construct($eventDispatcher = null, $table = 'users') { $this->cache = new CappedMemoryCache(); $this->table = $table; - $this->eventDispatcher = $eventDispatcher ? $eventDispatcher : \OC::$server->query(IEventDispatcher::class); + $this->eventDispatcher = $eventDispatcher ? $eventDispatcher : \OCP\Server::get(IEventDispatcher::class); } /** diff --git a/lib/private/User/User.php b/lib/private/User/User.php index 8f3192d070e..dc4cdec1235 100644 --- a/lib/private/User/User.php +++ b/lib/private/User/User.php @@ -117,7 +117,7 @@ class User implements IUser { $this->urlGenerator = \OC::$server->getURLGenerator(); } // TODO: inject - $this->dispatcher = \OC::$server->query(IEventDispatcher::class); + $this->dispatcher = \OCP\Server::get(IEventDispatcher::class); } /** @@ -299,7 +299,7 @@ class User implements IUser { \OC::$server->getCommentsManager()->deleteReadMarksFromUser($this); /** @var AvatarManager $avatarManager */ - $avatarManager = \OC::$server->query(AvatarManager::class); + $avatarManager = \OCP\Server::get(AvatarManager::class); $avatarManager->deleteUserAvatar($this->uid); $notification = \OC::$server->getNotificationManager()->createNotification(); @@ -307,7 +307,7 @@ class User implements IUser { \OC::$server->getNotificationManager()->markProcessed($notification); /** @var AccountManager $accountManager */ - $accountManager = \OC::$server->query(AccountManager::class); + $accountManager = \OCP\Server::get(AccountManager::class); $accountManager->deleteUser($this); /** @deprecated 21.0.0 use UserDeletedEvent event with the IEventDispatcher instead */ diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php index a1aeb50bbf4..9337492e775 100644 --- a/lib/private/legacy/OC_App.php +++ b/lib/private/legacy/OC_App.php @@ -52,7 +52,6 @@ declare(strict_types=1); */ use OCP\App\Events\AppUpdateEvent; -use OCP\AppFramework\QueryException; use OCP\App\IAppManager; use OCP\App\ManagerEvent; use OCP\Authentication\IAlternativeLogin; @@ -65,6 +64,7 @@ use OC\DB\MigrationService; use OC\Installer; use OC\Repair; use OC\Repair\Events\RepairErrorEvent; +use Psr\Container\ContainerExceptionInterface; use Psr\Log\LoggerInterface; /** @@ -255,7 +255,7 @@ class OC_App { array $groups = []) { // Check if app is already downloaded /** @var Installer $installer */ - $installer = \OC::$server->query(Installer::class); + $installer = \OCP\Server::get(Installer::class); $isDownloaded = $installer->isDownloaded($appId); if (!$isDownloaded) { @@ -463,7 +463,7 @@ class OC_App { */ public static function getAlternativeLogIns(): array { /** @var Coordinator $bootstrapCoordinator */ - $bootstrapCoordinator = \OC::$server->query(Coordinator::class); + $bootstrapCoordinator = \OCP\Server::get(Coordinator::class); foreach ($bootstrapCoordinator->getRegistrationContext()->getAlternativeLogins() as $registration) { if (!in_array(IAlternativeLogin::class, class_implements($registration->getService()), true)) { @@ -477,8 +477,8 @@ class OC_App { try { /** @var IAlternativeLogin $provider */ - $provider = \OC::$server->query($registration->getService()); - } catch (QueryException $e) { + $provider = \OCP\Server::get($registration->getService()); + } catch (ContainerExceptionInterface $e) { \OC::$server->getLogger()->logException($e, [ 'message' => 'Alternative login option {option} can not be initialised.', 'option' => $registration->getService(), @@ -543,7 +543,7 @@ class OC_App { */ public function getSupportedApps(): array { /** @var \OCP\Support\Subscription\IRegistry $subscriptionRegistry */ - $subscriptionRegistry = \OC::$server->query(\OCP\Support\Subscription\IRegistry::class); + $subscriptionRegistry = \OCP\Server::get(\OCP\Support\Subscription\IRegistry::class); $supportedApps = $subscriptionRegistry->delegateGetSupportedApps(); return $supportedApps; } diff --git a/lib/private/legacy/OC_Files.php b/lib/private/legacy/OC_Files.php index b6c45e164ef..7bc1fab94b6 100644 --- a/lib/private/legacy/OC_Files.php +++ b/lib/private/legacy/OC_Files.php @@ -333,7 +333,7 @@ class OC_Files { $rangeArray = self::parseHttpRangeHeader(substr($params['range'], 6), $fileSize); } - $dispatcher = \OC::$server->query(IEventDispatcher::class); + $dispatcher = \OCP\Server::get(IEventDispatcher::class); $event = new BeforeDirectFileDownloadEvent($filename); $dispatcher->dispatchTyped($event); diff --git a/lib/private/legacy/OC_Template.php b/lib/private/legacy/OC_Template.php index 0c9fa1ccc0c..70477ea6a06 100644 --- a/lib/private/legacy/OC_Template.php +++ b/lib/private/legacy/OC_Template.php @@ -83,7 +83,7 @@ class OC_Template extends \OC\Template\Base { $parts = explode('/', $app); // fix translation when app is something like core/lostpassword $l10n = \OC::$server->getL10N($parts[0]); /** @var \OCP\Defaults $themeDefaults */ - $themeDefaults = \OC::$server->query(\OCP\Defaults::class); + $themeDefaults = \OCP\Server::get(\OCP\Defaults::class); [$path, $template] = $this->findTemplate($theme, $app, $name); diff --git a/lib/private/legacy/template/functions.php b/lib/private/legacy/template/functions.php index 7081bd4f743..57c3a834128 100644 --- a/lib/private/legacy/template/functions.php +++ b/lib/private/legacy/template/functions.php @@ -308,7 +308,7 @@ function strip_time($timestamp) { */ function relative_modified_date($timestamp, $fromTime = null, $dateOnly = false) { /** @var \OC\DateTimeFormatter $formatter */ - $formatter = \OC::$server->query('DateTimeFormatter'); + $formatter = \OCP\Server::get('DateTimeFormatter'); if ($dateOnly) { return $formatter->formatDateSpan($timestamp, $fromTime); diff --git a/lib/public/AppFramework/Http/Response.php b/lib/public/AppFramework/Http/Response.php index d14d68d32b3..dd4f2c53418 100644 --- a/lib/public/AppFramework/Http/Response.php +++ b/lib/public/AppFramework/Http/Response.php @@ -119,7 +119,7 @@ class Response { // Set expires header $expires = new \DateTime(); /** @var ITimeFactory $time */ - $time = \OC::$server->query(ITimeFactory::class); + $time = \OCP\Server::get(ITimeFactory::class); $expires->setTimestamp($time->getTime()); $expires->add(new \DateInterval('PT'.$cacheSeconds.'S')); $this->addHeader('Expires', $expires->format(\DateTimeInterface::RFC2822)); diff --git a/lib/public/Util.php b/lib/public/Util.php index 5bb126d26b0..63ed9e835c7 100644 --- a/lib/public/Util.php +++ b/lib/public/Util.php @@ -49,6 +49,7 @@ namespace OCP; use OC\AppScriptDependency; use OC\AppScriptSort; use bantu\IniGetWrapper\IniGetWrapper; +use Psr\Container\ContainerExceptionInterface; /** * This class provides different helper functions to make the life of a developer easier @@ -83,9 +84,9 @@ class Util { public static function hasExtendedSupport(): bool { try { /** @var \OCP\Support\Subscription\IRegistry */ - $subscriptionRegistry = \OC::$server->query(\OCP\Support\Subscription\IRegistry::class); + $subscriptionRegistry = \OCP\Server::get(\OCP\Support\Subscription\IRegistry::class); return $subscriptionRegistry->delegateHasExtendedSupport(); - } catch (AppFramework\QueryException $e) { + } catch (ContainerExceptionInterface $e) { } return \OC::$server->getConfig()->getSystemValueBool('extendedSupport', false); } |