diff options
author | Christoph Wurst <ChristophWurst@users.noreply.github.com> | 2022-10-19 17:18:17 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-19 17:18:17 +0300 |
commit | 09192a73e3a244d87b08311fd90cd8346af287b6 (patch) | |
tree | 79b22c35de0187f3c2481043b1f9b794c20fb241 | |
parent | eb035630e2ca67195da30371c0403e6873c64d8c (diff) | |
parent | 17f8fbdda82754ab31e63f1d140f93655b57f630 (diff) |
Merge pull request #2869 from nextcloud/bug/avoid-undefined-offset-error
Avoid Undefined offset: 0 error by testing if the element exists before accessing it
-rw-r--r-- | lib/Service/SocialApiService.php | 6 |
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)]; } |