From 3c5e09f0b017b9c0102970ec2bb2a8473f1c9246 Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Fri, 27 Jan 2023 01:03:39 -0100 Subject: [PATCH] fix psalm Signed-off-by: Maxence Lange --- .../lib/OCM/CloudFederationProviderFiles.php | 8 ++++++-- .../lib/Controller/ShareAPIController.php | 16 +++++++++++----- psalm.xml | 2 ++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php index 477943b97caf9..7f1acbdf51637 100644 --- a/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php +++ b/apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php @@ -61,6 +61,7 @@ use OCP\Share\IShare; use OCP\Util; use Psr\Container\ContainerExceptionInterface; +use Psr\Log\LoggerInterface; class CloudFederationProviderFiles implements ICloudFederationProvider { @@ -842,8 +843,11 @@ private function getUserDisplayName(string $userId): string { try { $slaveService = Server::get(\OCA\GlobalSiteSelector\Service\SlaveService::class); - } catch (ContainerExceptionInterface $e) { - \OC::$server->getLogger()->logException($e); + } catch (\Throwable $e) { + Server::get(LoggerInterface::class)->error( + $e->getMessage(), + ['exception' => $e] + ); return ''; } diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 2daa31a6886bc..93d1916c7a952 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -81,6 +81,8 @@ use OCP\Share\IManager; use OCP\Share\IShare; use OCP\UserStatus\IManager as IUserStatusManager; +use Psr\Container\ContainerExceptionInterface; +use Psr\Log\LoggerInterface; /** * Class Share20OCS @@ -372,7 +374,9 @@ private function fixMissingDisplayName(array $shares, ?array $updatedDisplayName $userIds = $updated = []; foreach ($shares as $share) { // share is federated and share have no display name yet - if ($share['share_type'] === IShare::TYPE_REMOTE && $share['share_with_displayname'] === '') { + if ($share['share_type'] === IShare::TYPE_REMOTE + && ($share['share_with'] ?? '') !== '' + && ($share['share_with_displayname'] ?? '') === '') { $userIds[] = $userId = $share['share_with']; if ($updatedDisplayName !== null && array_key_exists($userId, $updatedDisplayName)) { @@ -410,8 +414,7 @@ private function fixMissingDisplayName(array $shares, ?array $updatedDisplayName * @param bool $cacheOnly - do not reach LUS, get data from cache. * * @return array - * @psalm-suppress DeprecatedMethod - * @psalm-suppress UndefinedClass + * @throws ContainerExceptionInterface */ private function retrieveFederatedDisplayName(array $userIds, bool $cacheOnly = false): array { // check if gss is enabled and available @@ -423,8 +426,11 @@ private function retrieveFederatedDisplayName(array $userIds, bool $cacheOnly = try { $slaveService = Server::get(\OCA\GlobalSiteSelector\Service\SlaveService::class); - } catch (Exception $e) { - \OC::$server->getLogger()->logException($e); + } catch (\Throwable $e) { + Server::get(LoggerInterface::class)->error( + $e->getMessage(), + ['exception' => $e] + ); return []; } diff --git a/psalm.xml b/psalm.xml index dac8635b5be4a..e76226ab4f2dc 100644 --- a/psalm.xml +++ b/psalm.xml @@ -83,6 +83,7 @@ + @@ -126,6 +127,7 @@ +