Skip to content

Commit 2149378

Browse files
committed
fix(files_sharing): don't crash CleanupShareTarget when mount info is missing
The repair step "Cleanup share names with false conflicts" fatals with "Call to a member function getRootId() on null" when a problem share's old target has no entry in the recipient's cached mounts (e.g. the recipient has not logged in since the share was created). Guard the lookup the same way the generateUniqueTarget callback already does and skip the mount cache refresh in that case - the share row is already updated by moveShare() and the cache is rebuilt on the user's next login. Fixes #63494 Signed-off-by: Baki Burak Öğün <63836730+bakiburakogun@users.noreply.github.com>
1 parent d7c20b7 commit 2149378

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

apps/files_sharing/lib/Repair/CleanupShareTarget.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,18 @@ public function run(IOutput $output) {
118118
$oldMountPoint = "/{$recipient->getUID()}/files$oldTarget/";
119119
$newMountPoint = "/{$recipient->getUID()}/files$newTarget/";
120120

121-
/** @var ICachedMountInfo $mount */
122-
$mount = $userMounts[$oldMountPoint];
123-
$userMounts[$newMountPoint] = $mount;
124-
unset($userMounts[$oldMountPoint]);
125-
126-
$this->userMountCache->removeMount($oldMountPoint);
127-
$this->userMountCache->addMount($recipient, $newMountPoint, new CacheEntry([
128-
'fileid' => $mount->getRootId(),
129-
'storage' => $mount->getStorageId(),
130-
]), $mount->getMountProvider(), $mount->getMountId());
121+
/** @var ICachedMountInfo|null $mount */
122+
$mount = $userMounts[$oldMountPoint] ?? null;
123+
if ($mount !== null) {
124+
$userMounts[$newMountPoint] = $mount;
125+
unset($userMounts[$oldMountPoint]);
126+
127+
$this->userMountCache->removeMount($oldMountPoint);
128+
$this->userMountCache->addMount($recipient, $newMountPoint, new CacheEntry([
129+
'fileid' => $mount->getRootId(),
130+
'storage' => $mount->getStorageId(),
131+
]), $mount->getMountProvider(), $mount->getMountId());
132+
}
131133
}
132134
} catch (\Exception $e) {
133135
$msg = 'error cleaning up share target: ' . $e->getMessage();

0 commit comments

Comments
 (0)