Skip to content

Commit 87b75fc

Browse files
authored
Merge pull request #42926 from nextcloud/backport/42891/stable27
[stable27] Improve path resolution in files_version hooks
2 parents 82fce12 + 91c8e79 commit 87b75fc

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

apps/files_versions/lib/Listener/FileEventsListener.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,16 +350,24 @@ public function pre_renameOrCopy_hook(Node $source, Node $target): void {
350350
private function getPathForNode(Node $node): ?string {
351351
$user = $this->userSession->getUser()?->getUID();
352352
if ($user) {
353-
return $this->rootFolder
353+
$path = $this->rootFolder
354354
->getUserFolder($user)
355355
->getRelativePath($node->getPath());
356+
357+
if ($path !== null) {
358+
return $path;
359+
}
356360
}
357361

358362
$owner = $node->getOwner()?->getUid();
359363
if ($owner) {
360-
return $this->rootFolder
364+
$path = $this->rootFolder
361365
->getUserFolder($owner)
362366
->getRelativePath($node->getPath());
367+
368+
if ($path !== null) {
369+
return $path;
370+
}
363371
}
364372

365373
return null;

0 commit comments

Comments
 (0)