Skip to content

Commit e09016d

Browse files
committed
fix: ensure options is always an array
Signed-off-by: Daniel Kesselberg <[email protected]>
1 parent d5d408c commit e09016d

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

lib/Folder/FolderManager.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,16 +549,33 @@ public function searchUsers(int $id, string $search = '', int $limit = 10, int $
549549
return array_values($users);
550550
}
551551

552+
private function getFolderOptions(array $row): array {
553+
if (!isset($row['options'])) {
554+
return [];
555+
}
556+
557+
try {
558+
$options = json_decode($row['options'], true, 512, JSON_THROW_ON_ERROR);
559+
} catch (\JsonException $e) {
560+
return [];
561+
}
562+
563+
if (!is_array($options)) {
564+
return [];
565+
}
566+
567+
return $options;
568+
}
569+
552570
private function rowToFolder(array $row): FolderDefinition {
553-
$options = json_decode($row['options'], true);
554571
return new FolderDefinition(
555572
(int)$row['folder_id'],
556573
(string)$row['mount_point'],
557574
$this->getRealQuota((int)$row['quota']),
558575
(bool)$row['acl'],
559576
(int)$row['storage_id'],
560577
(int)$row['root_id'],
561-
is_array($options) ? $options : [],
578+
$this->getFolderOptions($row),
562579
);
563580
}
564581

0 commit comments

Comments
 (0)