diff --git a/lib/private/Collaboration/Collaborators/Search.php b/lib/private/Collaboration/Collaborators/Search.php index c57e8f43fa050..b02640c5054e2 100644 --- a/lib/private/Collaboration/Collaborators/Search.php +++ b/lib/private/Collaboration/Collaborators/Search.php @@ -92,8 +92,6 @@ protected function dropMailSharesWhereRemoteShareIsPossible(ISearchResult $searc $allResults = $searchResult->asArray(); $emailType = new SearchResultType('emails'); - $remoteType = new SearchResultType('remotes'); - $emailLabel = $emailType->getLabel(); $emailEntries = array_merge( $allResults['exact'][$emailLabel] ?? [], @@ -112,14 +110,18 @@ protected function dropMailSharesWhereRemoteShareIsPossible(ISearchResult $searc $mailIdMap[$mailRow['uuid']] = $mailRow['value']['shareWith']; } - foreach ($allResults[$remoteType->getLabel()] as $resultRow) { - if (!isset($resultRow['uuid'])) { - continue; - } - if (isset($mailIdMap[$resultRow['uuid']])) { - $searchResult->removeCollaboratorResult($emailType, $mailIdMap[$resultRow['uuid']]); + $remoteType = new SearchResultType('remotes'); + if (isset($allResults[$remoteType->getLabel()])) { + foreach ($allResults[$remoteType->getLabel()] as $resultRow) { + if (!isset($resultRow['uuid'])) { + continue; + } + if (isset($mailIdMap[$resultRow['uuid']])) { + $searchResult->removeCollaboratorResult($emailType, $mailIdMap[$resultRow['uuid']]); + } } } + $lookupType = new SearchResultType('lookup'); if (isset($allResults[$lookupType->getLabel()])) { foreach ($allResults[$lookupType->getLabel()] as $resultRow) {