Skip to content

Commit

Permalink
Enforce string for folder id when obtaining the trash folder
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Jun 17, 2021
1 parent 7f25c64 commit ab69b1e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/Folder/FolderManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public function getFolder($id, $rootStorageId) {
$result->closeCursor();

return $row ? [
'id' => $id,
'id' => (int)$id,
'mount_point' => $row['mount_point'],
'groups' => isset($applicableMap[$id]) ? $applicableMap[$id] : [],
'quota' => $row['quota'],
Expand Down
6 changes: 3 additions & 3 deletions lib/Trash/TrashBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ private function getNodeForTrashItem(IUser $user, ITrashItem $trashItem) {
$folders = $this->folderManager->getFoldersForUser($user);
foreach ($folders as $groupFolder) {
if ($groupFolder['folder_id'] === (int)$folderId) {
$trashRoot = $this->getTrashFolder($folderId);
$trashRoot = $this->getTrashFolder((int)$folderId);
try {
$node = $trashRoot->get($path);
if (!$this->userHasAccessToPath($user, $folderId . '/' . $trashItem->getOriginalLocation())) {
Expand All @@ -245,13 +245,13 @@ private function getNodeForTrashItem(IUser $user, ITrashItem $trashItem) {
return null;
}

private function getTrashFolder($folderId) {
private function getTrashFolder(int $folderId) {
try {
return $this->appFolder->get('trash/' . $folderId);
} catch (NotFoundException $e) {
/** @var Folder $trashRoot */
$trashRoot = $this->appFolder->nodeExists('trash') ? $this->appFolder->get('trash') : $this->appFolder->newFolder('trash');
return $trashRoot->newFolder($folderId);
return $trashRoot->newFolder((string)$folderId);
}
}

Expand Down

0 comments on commit ab69b1e

Please sign in to comment.