Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1811,23 +1811,6 @@ private function getDeckShareHelper() {
return $this->serverContainer->get('\OCA\Deck\Sharing\ShareAPIHelper');
}

/**
* Returns the helper of ShareAPIHelper for sciencemesh shares.
*
* If the sciencemesh application is not enabled or the helper is not available
* a ContainerExceptionInterface is thrown instead.
*
* @return ShareAPIHelper
* @throws ContainerExceptionInterface
*/
private function getSciencemeshShareHelper() {
if (!$this->appManager->isEnabledForUser('sciencemesh')) {
throw new QueryException();
}

return $this->serverContainer->get('\OCA\ScienceMesh\Sharing\ShareAPIHelper');
}

/**
* @param string $viewer
* @param Node $node
Expand Down
4 changes: 2 additions & 2 deletions apps/workflowengine/tests/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use OCA\WorkflowEngine\Helper\ScopeContext;
use OCA\WorkflowEngine\Manager;
use OCP\App\IAppManager;
use OCP\AppFramework\QueryException;
use OCP\AppFramework\Services\IAppConfig;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventDispatcher;
Expand All @@ -37,6 +36,7 @@
use OCP\WorkflowEngine\IRuleMatcher;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
use Test\TestCase;
Expand Down Expand Up @@ -327,7 +327,7 @@ public function testGetOperations(): void {
case 'OCA\WFE\TestOp':
return $operation;
case 'OCA\WFE\OtherTestOp':
throw new QueryException();
throw $this->createMock(ContainerExceptionInterface::class);
}
});

Expand Down
3 changes: 1 addition & 2 deletions lib/private/AppFramework/Bootstrap/Coordinator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use OCP\App\IAppManager;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\QueryException;
use OCP\Dashboard\IManager;
use OCP\Diagnostics\IEventLogger;
use OCP\EventDispatcher\IEventDispatcher;
Expand Down Expand Up @@ -166,7 +165,7 @@ public function bootApp(string $appId): void {
$context = new BootContext($application->getContainer());
$application->boot($context);
}
} catch (QueryException $e) {
} catch (ContainerExceptionInterface $e) {
$this->logger->error("Could not boot $appId: " . $e->getMessage(), [
'exception' => $e,
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
use OCP\L10N\IFactory;
use OCP\Security\Ip\IRemoteAddress;
use OCP\Server;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -342,12 +343,12 @@ public function query(string $name, bool $autoload = true, array $chain = []): m

try {
return $this->queryNoFallback($name, $chain);
} catch (QueryException $firstException) {
} catch (ContainerExceptionInterface $firstException) {
try {
/** @var ServerContainer $server */
$server = $this->getServer();
return $server->query($name, $autoload, $chain);
} catch (QueryException $secondException) {
} catch (ContainerExceptionInterface $secondException) {
if ($firstException->getCode() === 1) {
throw $secondException;
}
Expand All @@ -360,7 +361,7 @@ public function query(string $name, bool $autoload = true, array $chain = []): m
* @param string $name
* @param list<class-string> $chain
* @return mixed
* @throws QueryException if the query could not be resolved
* @throws ContainerExceptionInterface if the query could not be resolved
*/
public function queryNoFallback($name, array $chain) {
$name = $this->sanitizeName($name);
Expand Down
6 changes: 3 additions & 3 deletions lib/private/Authentication/TwoFactorAuth/ProviderLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
use Exception;
use OC\AppFramework\Bootstrap\Coordinator;
use OCP\App\IAppManager;
use OCP\AppFramework\QueryException;
use OCP\Authentication\TwoFactorAuth\IProvider;
use OCP\IUser;
use OCP\Server;
use Psr\Container\ContainerExceptionInterface;

class ProviderLoader {
public const BACKUP_CODES_APP_ID = 'twofactor_backupcodes';
Expand Down Expand Up @@ -50,7 +50,7 @@ public function getProviders(?IUser $user = null): array {
$this->loadTwoFactorApp($appId);
$provider = Server::get($class);
$providers[$provider->getId()] = $provider;
} catch (QueryException $exc) {
} catch (ContainerExceptionInterface $exc) {
// Provider class can not be resolved
throw new Exception("Could not load two-factor auth provider $class");
}
Expand All @@ -64,7 +64,7 @@ public function getProviders(?IUser $user = null): array {
$this->loadTwoFactorApp($provider->getAppId());
$providerInstance = Server::get($provider->getService());
$providers[$providerInstance->getId()] = $providerInstance;
} catch (QueryException $exc) {
} catch (ContainerExceptionInterface $exc) {
// Provider class can not be resolved
throw new Exception('Could not load two-factor auth provider ' . $provider->getService());
}
Expand Down
6 changes: 3 additions & 3 deletions lib/private/Calendar/Resource/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

use OC\AppFramework\Bootstrap\Coordinator;
use OC\Calendar\ResourcesRoomsUpdater;
use OCP\AppFramework\QueryException;
use OCP\Calendar\Resource\IBackend;
use OCP\Calendar\Resource\IManager;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;

class Manager implements IManager {
Expand Down Expand Up @@ -73,7 +73,7 @@ private function fetchBootstrapBackends(): void {

/**
* @return IBackend[]
* @throws QueryException
* @throws ContainerExceptionInterface
* @since 14.0.0
*/
#[\Override]
Expand All @@ -93,7 +93,7 @@ public function getBackends():array {

/**
* @param string $backendId
* @throws QueryException
* @throws ContainerExceptionInterface
*/
#[\Override]
public function getBackend($backendId): ?IBackend {
Expand Down
6 changes: 3 additions & 3 deletions lib/private/Calendar/Room/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

use OC\AppFramework\Bootstrap\Coordinator;
use OC\Calendar\ResourcesRoomsUpdater;
use OCP\AppFramework\QueryException;
use OCP\Calendar\Room\IBackend;
use OCP\Calendar\Room\IManager;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;

class Manager implements IManager {
Expand Down Expand Up @@ -74,7 +74,7 @@ private function fetchBootstrapBackends(): void {

/**
* @return IBackend[]
* @throws QueryException
* @throws ContainerExceptionInterface
* @since 14.0.0
*/
#[\Override]
Expand All @@ -100,7 +100,7 @@ public function getBackends():array {

/**
* @param string $backendId
* @throws QueryException
* @throws ContainerExceptionInterface
*/
#[\Override]
public function getBackend($backendId): ?IBackend {
Expand Down
4 changes: 2 additions & 2 deletions lib/private/CapabilitiesManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

namespace OC;

use OCP\AppFramework\QueryException;
use OCP\Capabilities\ICapability;
use OCP\Capabilities\IInitialStateExcludedCapability;
use OCP\Capabilities\IPublicCapability;
use OCP\ILogger;
use Psr\Container\ContainerExceptionInterface;
use Psr\Log\LoggerInterface;

class CapabilitiesManager {
Expand Down Expand Up @@ -44,7 +44,7 @@ public function getCapabilities(bool $public = false, bool $initialState = false
foreach ($this->capabilities as $capability) {
try {
$c = $capability();
} catch (QueryException $e) {
} catch (ContainerExceptionInterface $e) {
$this->logger->error('CapabilitiesManager', [
'exception' => $e,
]);
Expand Down
4 changes: 2 additions & 2 deletions lib/private/Collaboration/Collaborators/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

namespace OC\Collaboration\Collaborators;

use OCP\AppFramework\QueryException;
use OCP\Collaboration\Collaborators\ISearch;
use OCP\Collaboration\Collaborators\ISearchPlugin;
use OCP\Collaboration\Collaborators\ISearchResult;
use OCP\Collaboration\Collaborators\SearchResultType;
use OCP\IContainer;
use OCP\Share\IShare;
use Psr\Container\ContainerExceptionInterface;

class Search implements ISearch {
protected array $pluginList = [];
Expand All @@ -28,7 +28,7 @@ public function __construct(
* @param bool $lookup
* @param int|null $limit
* @param int|null $offset
* @throws QueryException
* @throws ContainerExceptionInterface
*/
#[\Override]
public function search($search, array $shareTypes, $lookup, $limit, $offset): array {
Expand Down
4 changes: 2 additions & 2 deletions lib/private/Collaboration/Resources/ProviderManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

namespace OC\Collaboration\Resources;

use OCP\AppFramework\QueryException;
use OCP\Collaboration\Resources\IProvider;
use OCP\Collaboration\Resources\IProviderManager;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;

Expand All @@ -34,7 +34,7 @@ public function getResourceProviders(): array {
foreach ($this->providers as $provider) {
try {
$this->providerInstances[] = $this->serverContainer->get($provider);
} catch (QueryException $e) {
} catch (ContainerExceptionInterface $e) {
$this->logger->error("Could not query resource provider $provider: " . $e->getMessage(), [
'exception' => $e,
]);
Expand Down
4 changes: 2 additions & 2 deletions lib/private/Contacts/ContactsMenu/ActionProviderStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
use OC\Contacts\ContactsMenu\Providers\EMailProvider;
use OC\Contacts\ContactsMenu\Providers\LocalTimeProvider;
use OC\Contacts\ContactsMenu\Providers\ProfileProvider;
use OCP\AppFramework\QueryException;
use OCP\Contacts\ContactsMenu\IBulkProvider;
use OCP\Contacts\ContactsMenu\IProvider;
use OCP\IUser;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -50,7 +50,7 @@ public function getProviders(IUser $user): array {
'class' => $class,
]);
}
} catch (QueryException $ex) {
} catch (ContainerExceptionInterface $ex) {
$this->logger->error(
'Could not load contacts menu action provider ' . $class,
[
Expand Down
4 changes: 2 additions & 2 deletions lib/private/EventDispatcher/ServiceEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

namespace OC\EventDispatcher;

use OCP\AppFramework\QueryException;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
use function sprintf;
Expand Down Expand Up @@ -39,7 +39,7 @@ public function __invoke(Event $event) {
// parameters and aliases won't be resolved.
// See https://github.com/nextcloud/server/issues/27793 for details.
$this->service = $this->container->get($this->class);
} catch (QueryException $e) {
} catch (ContainerExceptionInterface $e) {
$this->logger->error(
sprintf(
'Could not load event listener service %s: %s. Make sure the class is auto-loadable by the Nextcloud server container',
Expand Down
4 changes: 2 additions & 2 deletions lib/private/Http/WellKnown/RequestManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

use OC\AppFramework\Bootstrap\Coordinator;
use OC\AppFramework\Bootstrap\ServiceRegistration;
use OCP\AppFramework\QueryException;
use OCP\Http\WellKnown\IHandler;
use OCP\Http\WellKnown\IRequestContext;
use OCP\Http\WellKnown\IResponse;
use OCP\Http\WellKnown\JrdResponse;
use OCP\IRequest;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
use RuntimeException;
Expand Down Expand Up @@ -85,7 +85,7 @@ private function loadHandlers(): array {
}

return $handler;
} catch (QueryException $e) {
} catch (ContainerExceptionInterface $e) {
$this->logger->error("Could not load well known handler $class", [
'exception' => $e,
'app' => $registration->getAppId(),
Expand Down
6 changes: 3 additions & 3 deletions lib/private/InitialStateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

use Closure;
use OC\AppFramework\Bootstrap\Coordinator;
use OCP\AppFramework\QueryException;
use OCP\AppFramework\Services\InitialStateProvider;
use OCP\IInitialStateService;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -94,8 +94,8 @@ private function loadLazyStates(): void {
$initialStates = $context->getInitialStates();
foreach ($initialStates as $initialState) {
try {
$provider = $this->container->query($initialState->getService());
} catch (QueryException $e) {
$provider = $this->container->get($initialState->getService());
} catch (ContainerExceptionInterface $e) {
// Log an continue. We can be fault tolerant here.
$this->logger->error('Could not load initial state provider dynamically: ' . $e->getMessage(), [
'exception' => $e,
Expand Down
13 changes: 7 additions & 6 deletions lib/private/ServerContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use OC\AppFramework\DependencyInjection\DIContainer;
use OC\AppFramework\Utility\SimpleContainer;
use OCP\AppFramework\QueryException;
use Psr\Container\ContainerExceptionInterface;
use function explode;
use function strtolower;

Expand Down Expand Up @@ -60,7 +61,7 @@
/**
* @param string $appName
* @return DIContainer
* @throws QueryException
* @throws ContainerExceptionInterface
*/
public function getRegisteredAppContainer(string $appName): DIContainer {
if (isset($this->appContainers[strtolower(App::buildAppNamespace($appName))])) {
Expand All @@ -74,7 +75,7 @@
* @param string $namespace
* @param string $sensitiveNamespace
* @return DIContainer
* @throws QueryException
* @throws ContainerExceptionInterface
*/
protected function getAppContainer(string $sensitiveNamespace): DIContainer {
$namespace = strtolower($sensitiveNamespace);
Expand All @@ -87,7 +88,7 @@
$applicationClassName = $sensitiveNamespace . '\\AppInfo\\Application';
if (class_exists($applicationClassName)) {
/* The application constructor will register the container, see App::__construct */
$app = new $applicationClassName();

Check failure on line 91 in lib/private/ServerContainer.php

View workflow job for this annotation

GitHub Actions / static-code-analysis-security

TaintedCallable

lib/private/ServerContainer.php:91:17: TaintedCallable: Detected tainted text (see https://psalm.dev/243)
if (isset($this->appContainers[$namespace])) {
$this->appContainers[$namespace]->offsetSet($applicationClassName, $app);
/** @psalm-suppress NoValue false-positive (see comment above) */
Expand Down Expand Up @@ -119,7 +120,7 @@
* @psalm-template S as class-string<T>|string
* @psalm-param S $name
* @psalm-return (S is class-string<T> ? T : mixed)
* @throws QueryException
* @throws ContainerExceptionInterface
* @deprecated 20.0.0 use \Psr\Container\ContainerInterface::get
*/
#[\Override]
Expand All @@ -130,15 +131,15 @@
// Skip server container query for app namespace classes
try {
return parent::query($name, false, $chain);
} catch (QueryException $e) {
} catch (ContainerExceptionInterface $e) {
// Continue with general autoloading then
}
// In case the service starts with OCA\ we try to find the service in
// the apps container first.
if (($appContainer = $this->getAppContainerForService($name)) !== null) {
try {
return $appContainer->queryNoFallback($name, $chain);
} catch (QueryException $e) {
} catch (ContainerExceptionInterface $e) {
// Didn't find the service or the respective app container
// In this case the service won't be part of the core container,
// so we can throw directly
Expand All @@ -163,7 +164,7 @@
try {
[,$namespace,] = explode('\\', $id, 3);
return $this->getAppContainer('OCA\\' . $namespace);
} catch (QueryException $e) {
} catch (ContainerExceptionInterface $e) {
return null;
}
}
Expand Down
Loading
Loading