mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 00:02:54 -04:00
fix(ViewController): Regression lead to 500 on non-existent fileIds
Fixes #42418 Signed-off-by: Josh Richards <josh.t.richards@gmail.com>
This commit is contained in:
parent
30f23a6da7
commit
1f6f5fdcc5
1 changed files with 10 additions and 6 deletions
|
|
@ -237,12 +237,16 @@ class ViewController extends Controller {
|
|||
if ($fileid && $dir !== '') {
|
||||
$baseFolder = $this->rootFolder->getUserFolder($userId);
|
||||
$nodes = $baseFolder->getById((int) $fileid);
|
||||
$nodePath = $baseFolder->getRelativePath($nodes[0]->getPath());
|
||||
$relativePath = $nodePath ? dirname($nodePath) : '';
|
||||
// If the requested path does not contain the file id
|
||||
// or if the requested path is not the file id itself
|
||||
if (count($nodes) === 1 && $relativePath !== $dir && $nodePath !== $dir) {
|
||||
return $this->redirectToFile((int) $fileid);
|
||||
if (!empty($nodes)) {
|
||||
$nodePath = $baseFolder->getRelativePath($nodes[0]->getPath());
|
||||
$relativePath = $nodePath ? dirname($nodePath) : '';
|
||||
// If the requested path does not contain the file id
|
||||
// or if the requested path is not the file id itself
|
||||
if (count($nodes) === 1 && $relativePath !== $dir && $nodePath !== $dir) {
|
||||
return $this->redirectToFile((int) $fileid);
|
||||
}
|
||||
} else { // fileid does not exist anywhere
|
||||
$fileNotFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue