Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <[email protected]>
  • Loading branch information
ArtificialOwl committed May 23, 2022
1 parent 93b0e96 commit e86e116
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/Service/ShareWrapperService.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public function getSharedWith(
throw new InvalidItemException();
}

return $this->deserializeArray($cachedData, ShareWrapper::class);
return $this->deserializeArrayFromJson($cachedData, ShareWrapper::class);
} catch (InvalidItemException $e) {
}

Expand Down
22 changes: 17 additions & 5 deletions lib/Tools/Traits/TDeserialize.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,29 @@ public function deserialize(array $data, string $class): IDeserializable {
* @param string $class
*
* @return IDeserializable[]
* @throws InvalidItemException
*/
public function deserializeArray(string $json, string $class): array {
$arr = [];
public function deserializeArrayFromJson(string $json, string $class): array {
$data = json_decode($json, true);
if (!is_array($data)) {
return $arr;
return [];
}

return $this->deserializeArray($data, $class);
}

/**
* @param array $data
* @param string $class
*
* @return array
*/
public function deserializeArray(array $data, string $class): array {
$arr = [];
foreach ($data as $entry) {
$arr[] = $this->deserialize($entry, $class);
try {
$arr[] = $this->deserialize($entry, $class);
} catch (InvalidItemException $e) {
}
}

return $arr;
Expand Down

0 comments on commit e86e116

Please sign in to comment.