Skip to content

Commit

Permalink
Merge pull request #41518 from nextcloud/nullGetUid
Browse files Browse the repository at this point in the history
fix(files_versions): don't call getUid() on null
  • Loading branch information
artonge committed Nov 16, 2023
2 parents 7b45939 + 652317e commit 1b18b97
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/files_versions/lib/Listener/FileEventsListener.php
Expand Up @@ -351,16 +351,20 @@ public function pre_renameOrCopy_hook(Node $source, Node $target): void {

/**
* Retrieve the path relative to the current user root folder.
* If no user is connected, use the node's owner.
* If no user is connected, try to use the node's owner.
*/
private function getPathForNode(Node $node): ?string {
try {
return $this->rootFolder
->getUserFolder(\OC_User::getUser())
->getRelativePath($node->getPath());
} catch (\Throwable $ex) {
$owner = $node->getOwner();
if ($owner === null) {
return null;
}
return $this->rootFolder
->getUserFolder($node->getOwner()->getUid())
->getUserFolder($owner->getUid())
->getRelativePath($node->getPath());
}
}
Expand Down

0 comments on commit 1b18b97

Please sign in to comment.