diff -ur clean/html/apps/files_versions/lib/Listener/FileEventsListener.php patched/html/apps/files_versions/lib/Listener/FileEventsListener.php
--- clean/html/apps/files_versions/lib/Listener/FileEventsListener.php 2024-09-13 16:04:38.000000000 +0100
+++ patched/html/apps/files_versions/lib/Listener/FileEventsListener.php 2024-09-13 13:20:40.000000000 +0100
@@ -381,6 +381,26 @@
}
}
+ // If we are writing to a shared file that this user does not have access to, for
+ // instance when filling in a form on group storage with an attached spreadsheet,
+ // both $user and $owner will be the current UID, and the file may not be
+ // accessible from either. Try getting it from the path.
+ //
+ // Note that this is safe because this is a versioning hook: we must have already
+ // checked that the user has access to the file elsewhere in the code.
+
+ if ($owner == $user)
+ {
+ $parts = explode ('/', $node->getPath());
+ if (count ($parts) > 1) {
+ $oldOwner = $owner;
+ $owner = $parts[1];
+ $this->logger->warning("Assuming owner is actually ".$owner." not ".$oldOwner." for ".($node->getPath()));
+ }
+ $path = $this->rootFolder
+ ->getUserFolder($owner)
+ ->getRelativePath($node->getPath());
+
+ if ($path !== null) {
+ $this->logger->warning("Found path with fallback owner: ".$path);
+ return $path;
+ }
+ }
+
return null;
}
}