diff --git a/lib/public/share.php b/lib/public/share.php
index 8b8a41d47c0f21121b82e97ec02bf3c1d3627c46..4b337530be8200ecc2d941d19096728998174a0b 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -661,6 +661,7 @@ class Share {
 			}
 		}
 		$backend = self::getBackend($itemType);
+		$collectionTypes = false;
 		// Get filesystem root to add it to the file target and remove from the
 		// file source, match file_source with the file cache
 		if ($itemType == 'file' || $itemType == 'folder') {
@@ -1145,7 +1146,7 @@ class Share {
 				'itemTarget' => $groupItemTarget,
 				'parent' => $parent,
 				'shareType' => $shareType,
-				'shareWith' => $uid,
+				'shareWith' => $shareWith['group'],
 				'uidOwner' => $uidOwner,
 				'permissions' => $permissions,
 				'fileSource' => $fileSource,