fix(ShareMapper#findBySharedFolder): Make sure exceptions are caught

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
Marcel Klehr
2025-07-16 15:47:03 +02:00
parent 3462c0a5d4
commit f4b1c1a070
2 changed files with 11 additions and 1 deletions

View File

@ -177,6 +177,11 @@ class ShareMapper extends QBMapper {
return parent::insertOrUpdate($entity);
}
/**
* @throws DoesNotExistException
* @throws MultipleObjectsReturnedException
* @throws Exception
*/
public function findBySharedFolder(int $id): Share {
$qb = $this->db->getQueryBuilder();
$qb->select(array_map(static function ($c) {

View File

@ -919,7 +919,12 @@ class TreeMapper extends QBMapper {
return $array;
}, $this->findChildren(TreeMapper::TYPE_FOLDER, $folderId, $isSoftDeleted));
$shares = array_map(function (SharedFolder $sharedFolder) use ($layers, $folderId, $isSoftDeleted) {
$share = $this->shareMapper->findBySharedFolder($sharedFolder->getId());
try {
$share = $this->shareMapper->findBySharedFolder($sharedFolder->getId());
} catch (DoesNotExistException|MultipleObjectsReturnedException|Exception $e) {
$this->logger->error('Failed to load a shared folder', ['exception' => $e]);
return null;
}
$array = $sharedFolder->toArray();
$array['id'] = $share->getFolderId();
$array['userId'] = $share->getOwner();