summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnna <anna@nextcloud.com>2022-10-19 16:46:53 +0200
committerGitHub <noreply@github.com>2022-10-19 16:46:53 +0200
commit530bed38df16d1d457af2809f3366aef5c4bc70b (patch)
tree1e5f7654e2f1b76e3cda880187a2458db2fae50e
parentc80455899343bd5ee2530fea4e7c27350eba43c7 (diff)
parent4ba8c5acd150f5fd5e8d2eba77dfa67065ab569b (diff)
Merge pull request #3062 from nextcloud/backport/2869/stable5.0
[stable5.0] Avoid Undefined offset: 0 error by testing if the element exists before accessing it
-rw-r--r--lib/Service/SocialApiService.php6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Service/SocialApiService.php b/lib/Service/SocialApiService.php
index 3959eaf6..26a9adb2 100644
--- a/lib/Service/SocialApiService.php
+++ b/lib/Service/SocialApiService.php
@@ -186,12 +186,14 @@ class SocialApiService {
}
// search contact in that addressbook, get social data
- $contact = $addressBook->search($contactId, ['UID'], ['types' => true])[0];
+ $contacts = $addressBook->search($contactId, ['UID'], ['types' => true]);
- if (!isset($contact)) {
+ if (!isset($contacts[0])) {
return new JSONResponse([], Http::STATUS_PRECONDITION_FAILED);
}
+ $contact = $contacts[0];
+
if ($network) {
$allConnectors = [$this->socialProvider->getSocialConnector($network)];
}