From a2bd51fb4044b66aa0c9a7a3472da426acff7293 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Baki=20Burak=20=C3=96=C4=9F=C3=BCn?= <63836730+bakiburakogun@users.noreply.github.com> Date: Sun, 23 Aug 2026 03:24:33 +0300 Subject: [PATCH] fix(files_sharing): don't crash CleanupShareTarget when mount info is missing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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> --- .../lib/Repair/CleanupShareTarget.php | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/apps/files_sharing/lib/Repair/CleanupShareTarget.php b/apps/files_sharing/lib/Repair/CleanupShareTarget.php index 7a82869b773bc..53882dbe2e2e7 100644 --- a/apps/files_sharing/lib/Repair/CleanupShareTarget.php +++ b/apps/files_sharing/lib/Repair/CleanupShareTarget.php @@ -118,16 +118,18 @@ public function run(IOutput $output) { $oldMountPoint = "/{$recipient->getUID()}/files$oldTarget/"; $newMountPoint = "/{$recipient->getUID()}/files$newTarget/"; - /** @var ICachedMountInfo $mount */ - $mount = $userMounts[$oldMountPoint]; - $userMounts[$newMountPoint] = $mount; - unset($userMounts[$oldMountPoint]); - - $this->userMountCache->removeMount($oldMountPoint); - $this->userMountCache->addMount($recipient, $newMountPoint, new CacheEntry([ - 'fileid' => $mount->getRootId(), - 'storage' => $mount->getStorageId(), - ]), $mount->getMountProvider(), $mount->getMountId()); + /** @var ICachedMountInfo|null $mount */ + $mount = $userMounts[$oldMountPoint] ?? null; + if ($mount !== null) { + $userMounts[$newMountPoint] = $mount; + unset($userMounts[$oldMountPoint]); + + $this->userMountCache->removeMount($oldMountPoint); + $this->userMountCache->addMount($recipient, $newMountPoint, new CacheEntry([ + 'fileid' => $mount->getRootId(), + 'storage' => $mount->getStorageId(), + ]), $mount->getMountProvider(), $mount->getMountId()); + } } } catch (\Exception $e) { $msg = 'error cleaning up share target: ' . $e->getMessage();