Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion apps/dav/lib/DAV/Sharing/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ public function deleteAllSharesByUser(string $principaluri): void {
* @return list<array{href: string, commonName: string, status: int, readOnly: bool, '{http://owncloud.org/ns}principal': string, '{http://owncloud.org/ns}group-share': bool}>
*/
public function getShares(int $resourceId): array {
/** @var list<array{href: string, commonName: string, status: int, readOnly: bool, '{http://owncloud.org/ns}principal': string, '{http://owncloud.org/ns}group-share': bool}>|null $cached */
$cached = $this->shareCache->get((string)$resourceId);
if ($cached) {
if (is_array($cached)) {
return $cached;
}

Expand Down Expand Up @@ -161,6 +162,23 @@ public function preloadShares(array $resourceIds): void {
];
$this->shareCache->set((string)$resourceId, $sharesByResource[$resourceId]);
}

// Also remember resources with no shares to prevent superfluous (empty) queries later on
foreach ($resourceIds as $resourceId) {
$hasShares = false;
foreach ($rows as $row) {
if ((int)$row['resourceid'] === $resourceId) {
$hasShares = true;
break;
}
}

if ($hasShares) {
continue;
}

$this->shareCache->set((string)$resourceId, []);
}
}

/**
Expand Down
Loading