summaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorDariusz Olszewski <starypatyk@users.noreply.github.com>2022-10-07 23:24:12 +0200
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>2022-10-14 13:38:39 +0000
commit6119604f7153d0786ac0c8c2519a2dad892ab127 (patch)
treeba9926aecc88f0e545789f56b3500647cb54018c /apps/dav
parent684bd274b837df906d68ad38466d67c5935f9c72 (diff)
downloadnextcloud-server-6119604f7153d0786ac0c8c2519a2dad892ab127.tar.gz
nextcloud-server-6119604f7153d0786ac0c8c2519a2dad892ab127.zip
Read notes from share already loaded into memory
Signed-off-by: Dariusz Olszewski <starypatyk@users.noreply.github.com>
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/Connector/Sabre/Node.php26
1 files changed, 11 insertions, 15 deletions
diff --git a/apps/dav/lib/Connector/Sabre/Node.php b/apps/dav/lib/Connector/Sabre/Node.php
index 5fb811ad1ab..e1cbdeac7e0 100644
--- a/apps/dav/lib/Connector/Sabre/Node.php
+++ b/apps/dav/lib/Connector/Sabre/Node.php
@@ -355,23 +355,19 @@ abstract class Node implements \Sabre\DAV\INode {
return '';
}
- $types = [
- IShare::TYPE_USER,
- IShare::TYPE_GROUP,
- IShare::TYPE_CIRCLE,
- IShare::TYPE_ROOM
- ];
-
- foreach ($types as $shareType) {
- $shares = $this->shareManager->getSharedWith($user, $shareType, $this, -1);
- foreach ($shares as $share) {
- $note = $share->getNote();
- if ($share->getShareOwner() !== $user && !empty($note)) {
- return $note;
- }
- }
+ // Retrieve note from the share object already loaded into
+ // memory, to avoid additional database queries.
+ $storage = $this->getNode()->getStorage();
+ if (!$storage->instanceOfStorage(\OCA\Files_Sharing\SharedStorage::class)) {
+ return '';
}
+ /** @var \OCA\Files_Sharing\SharedStorage $storage */
+ $share = $storage->getShare();
+ $note = $share->getNote();
+ if ($share->getShareOwner() !== $user && !empty($note)) {
+ return $note;
+ }
return '';
}