]> source.dussan.org Git - nextcloud-server.git/commitdiff
Don't crash with outdated share provider
authorJoas Schilling <coding@schilljs.com>
Thu, 20 Oct 2022 06:44:57 +0000 (08:44 +0200)
committerJoas Schilling <coding@schilljs.com>
Thu, 20 Oct 2022 07:21:15 +0000 (09:21 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
lib/private/Share20/ProviderFactory.php

index 434c0017d21cb2a6cb5944a2db811e9c8ae7d06a..ff570cfa9938fdbc3567ea6c86963d1a41ad4c7a 100644 (file)
@@ -40,6 +40,7 @@ use OCA\FederatedFileSharing\Notifications;
 use OCA\FederatedFileSharing\TokenHandler;
 use OCA\ShareByMail\Settings\SettingsManager;
 use OCA\ShareByMail\ShareByMailProvider;
+use OCA\Talk\Share\RoomShareProvider;
 use OCP\Defaults;
 use OCP\EventDispatcher\IEventDispatcher;
 use OCP\IServerContainer;
@@ -47,6 +48,8 @@ use OCP\Share\IManager;
 use OCP\Share\IProviderFactory;
 use OCP\Share\IShare;
 use OCP\Share\IShareProvider;
+use Psr\Container\ContainerExceptionInterface;
+use Psr\Log\LoggerInterface;
 
 /**
  * Class ProviderFactory
@@ -257,8 +260,15 @@ class ProviderFactory implements IProviderFactory {
                        }
 
                        try {
-                               $this->roomShareProvider = $this->serverContainer->query('\OCA\Talk\Share\RoomShareProvider');
-                       } catch (\OCP\AppFramework\QueryException $e) {
+                               /**
+                                * @psalm-suppress UndefinedClass
+                                */
+                               $this->roomShareProvider = $this->serverContainer->get(RoomShareProvider::class);
+                       } catch (\Throwable $e) {
+                               $this->serverContainer->get(LoggerInterface::class)->error(
+                                       $e->getMessage(),
+                                       ['exception' => $e]
+                               );
                                return null;
                        }
                }
@@ -351,8 +361,17 @@ class ProviderFactory implements IProviderFactory {
                }
 
                foreach ($this->registeredShareProviders as $shareProvider) {
-                       /** @var IShareProvider $instance */
-                       $instance = $this->serverContainer->get($shareProvider);
+                       try {
+                               /** @var IShareProvider $instance */
+                               $instance = $this->serverContainer->get($shareProvider);
+                       } catch (\Throwable $e) {
+                               $this->serverContainer->get(LoggerInterface::class)->error(
+                                       $e->getMessage(),
+                                       ['exception' => $e]
+                               );
+                               continue;
+                       }
+
                        if (!isset($this->shareProviders[$instance->identifier()])) {
                                $this->shareProviders[$instance->identifier()] = $instance;
                        }