Code Duplication    Length = 12-12 lines in 2 locations

lib/private/Share/Share.php 2 locations

@@ 743-754 (lines=12) @@
740
				}
741
			}
742
			// Check if the item source is already shared with the user, either from the same owner or a different user
743
			if ($checkExists = self::getItems($itemType, $itemSource, self::$shareTypeUserAndGroups,
744
				$shareWith, null, self::FORMAT_NONE, null, 1, true, true)) {
745
				// Only allow the same share to occur again if it is the same
746
				// owner and is not a user share, this use case is for increasing
747
				// permissions for a specific user
748
				if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) {
749
					$message = 'Sharing %s failed, because this item is already shared with %s';
750
					$message_t = $l->t('Sharing %s failed, because this item is already shared with %s', [$itemSourceName, $shareWith]);
751
					\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG);
752
					throw new \Exception($message_t);
753
				}
754
			}
755
			if ($checkExists = self::getItems($itemType, $itemSource, self::SHARE_TYPE_USER,
756
				$shareWith, null, self::FORMAT_NONE, null, 1, true, true)) {
757
				// Only allow the same share to occur again if it is the same
@@ 755-766 (lines=12) @@
752
					throw new \Exception($message_t);
753
				}
754
			}
755
			if ($checkExists = self::getItems($itemType, $itemSource, self::SHARE_TYPE_USER,
756
				$shareWith, null, self::FORMAT_NONE, null, 1, true, true)) {
757
				// Only allow the same share to occur again if it is the same
758
				// owner and is not a user share, this use case is for increasing
759
				// permissions for a specific user
760
				if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) {
761
					$message = 'Sharing %s failed, because this item is already shared with user %s';
762
					$message_t = $l->t('Sharing %s failed, because this item is already shared with user %s', [$itemSourceName, $shareWith]);
763
					\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::ERROR);
764
					throw new \Exception($message_t);
765
				}
766
			}
767
		} else if ($shareType === self::SHARE_TYPE_GROUP) {
768
			if (!\OC::$server->getGroupManager()->groupExists($shareWith)) {
769
				$message = 'Sharing %s failed, because the group %s does not exist';