diff options
author | Simon L <szaimen@e.mail.de> | 2022-10-20 23:50:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-20 23:50:15 +0200 |
commit | 9aaa370e07099484df025ec95e017a7baa4e3633 (patch) | |
tree | 2db9d69fcd767125637b164a0f4a9d27831af43f /lib/private | |
parent | 72744a71c95df32d9cb97558ef8aaec7bbc8be4b (diff) | |
parent | 3dee71db2095e7ee4113753c25dd174c04ddd060 (diff) | |
download | nextcloud-server-9aaa370e07099484df025ec95e017a7baa4e3633.tar.gz nextcloud-server-9aaa370e07099484df025ec95e017a7baa4e3633.zip |
Merge pull request #34688 from nextcloud/bugfix/34673/dont-crash-with-outdated-share-providers
Don't crash with outdated share provider on update with the web updater
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/Share20/ProviderFactory.php | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/lib/private/Share20/ProviderFactory.php b/lib/private/Share20/ProviderFactory.php index 434c0017d21..9bba4d771aa 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,7 @@ use OCP\Share\IManager; use OCP\Share\IProviderFactory; use OCP\Share\IShare; use OCP\Share\IShareProvider; +use Psr\Log\LoggerInterface; /** * Class ProviderFactory @@ -257,8 +259,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; } } @@ -288,9 +297,16 @@ class ProviderFactory implements IProviderFactory { } foreach ($this->registeredShareProviders as $shareProvider) { - /** @var IShareProvider $instance */ - $instance = $this->serverContainer->get($shareProvider); - $this->shareProviders[$instance->identifier()] = $instance; + try { + /** @var IShareProvider $instance */ + $instance = $this->serverContainer->get($shareProvider); + $this->shareProviders[$instance->identifier()] = $instance; + } catch (\Throwable $e) { + $this->serverContainer->get(LoggerInterface::class)->error( + $e->getMessage(), + ['exception' => $e] + ); + } } if (isset($this->shareProviders[$id])) { @@ -351,8 +367,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; } |