diff --git a/lib/Service/ShareWrapperService.php b/lib/Service/ShareWrapperService.php index 17bd1c6f2..df09aac0a 100644 --- a/lib/Service/ShareWrapperService.php +++ b/lib/Service/ShareWrapperService.php @@ -227,7 +227,7 @@ public function getSharedWith( throw new InvalidItemException(); } - return $this->deserializeArray($cachedData, ShareWrapper::class); + return $this->deserializeList($cachedData, ShareWrapper::class); } catch (InvalidItemException $e) { } diff --git a/lib/Tools/Traits/TDeserialize.php b/lib/Tools/Traits/TDeserialize.php index 82020e35c..7652cb319 100644 --- a/lib/Tools/Traits/TDeserialize.php +++ b/lib/Tools/Traits/TDeserialize.php @@ -77,6 +77,34 @@ public function deserialize(array $data, string $class): IDeserializable { } + /** + * @param array $data + * @param string $class + * @param bool $associative + * + * @return IDeserializable[] + */ + public function deserializeArray(array $data, string $class, bool $associative = false): array { + $arr = []; + foreach ($data as $key => $entry) { + if (!is_array($entry)) { + continue; + } + + try { + if ($associative) { + $arr[$key] = $this->deserialize($entry, $class); + } else { + $arr[] = $this->deserialize($entry, $class); + } + } catch (InvalidItemException $e) { + } + } + + return $arr; + } + + /** * @param string $json * @param string $class @@ -84,7 +112,7 @@ public function deserialize(array $data, string $class): IDeserializable { * @return IDeserializable[] * @throws InvalidItemException */ - public function deserializeArray(string $json, string $class): array { + public function deserializeList(string $json, string $class): array { $arr = []; $data = json_decode($json, true); if (!is_array($data)) { @@ -99,6 +127,7 @@ public function deserializeArray(string $json, string $class): array { } + /** * @param string $json * @param string $class