Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce string for folder id when obtaining the trash folder #1472

Merged
merged 1 commit into from
Jun 17, 2021
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/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