diff --git a/lib/FilesHooks.php b/lib/FilesHooks.php index 8f7e75f78..d5d31c2b2 100644 --- a/lib/FilesHooks.php +++ b/lib/FilesHooks.php @@ -826,7 +826,7 @@ public function unShareSelf(IShare $share) { if (in_array($share->getNodeType(), ['file', 'folder'], true)) { if ($share->getShareType() === IShare::TYPE_GROUP) { $this->unshareFromSelfGroup($share); - } else { + } elseif ($share->getShareType() === IShare::TYPE_USER) { $this->unshareFromUser($share); } } diff --git a/tests/FilesHooksTest.php b/tests/FilesHooksTest.php index 00dfbff0d..b1ebafc83 100644 --- a/tests/FilesHooksTest.php +++ b/tests/FilesHooksTest.php @@ -962,6 +962,8 @@ public function testLeaveShare(): void { ->willReturn('file'); $share->method('getSharedWith') ->willReturn('with'); + $share->method('getShareType') + ->willReturn(IShare::TYPE_USER); $this->settings->expects($this->exactly(3)) ->method('getUserSetting')