diff options
author | Joas Schilling <coding@schilljs.com> | 2022-10-20 08:44:57 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-10-20 09:21:15 +0200 |
commit | 40d8ed9edb514dc5d5487e3b3c09a8c8c51b023e (patch) | |
tree | 6c1f37e753e01a32fa293fe2e97b7ac692a4cd39 /lib | |
parent | 53b6d67bc19dfb75b6be64cae9ffeaf6fbfbdd6d (diff) | |
download | nextcloud-server-40d8ed9edb514dc5d5487e3b3c09a8c8c51b023e.tar.gz nextcloud-server-40d8ed9edb514dc5d5487e3b3c09a8c8c51b023e.zip |
Don't crash with outdated share provider
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Share20/ProviderFactory.php | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/lib/private/Share20/ProviderFactory.php b/lib/private/Share20/ProviderFactory.php index 434c0017d21..ff570cfa993 100644 --- a/lib/private/Share20/ProviderFactory.php +++ b/lib/private/Share20/ProviderFactory.php @@ -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; } |