Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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->deserializeList($cachedData, ShareWrapper::class);
} catch (InvalidItemException $e) {
}

Expand Down
31 changes: 30 additions & 1 deletion lib/Tools/Traits/TDeserialize.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,42 @@ 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
*
* @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)) {
Expand All @@ -99,6 +127,7 @@ public function deserializeArray(string $json, string $class): array {
}



/**
* @param string $json
* @param string $class
Expand Down