diff options
author | Christoph Wurst <ChristophWurst@users.noreply.github.com> | 2022-10-19 16:28:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-19 16:28:05 +0200 |
commit | 836b3cbf433d4cbd0206964ee5e886c61db4959e (patch) | |
tree | 251124c07904c03fb656b35436bf246345bd4146 | |
parent | cc41cfb3ddcda7e0581255746e00441b5590bea1 (diff) | |
parent | b2a3d2493244a85ca5f8813979461f3a70da2d27 (diff) |
Merge pull request #3061 from nextcloud/backport/2869/stable4.2
[stable4.2] 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 9a27a93d..cc32cbcc 100644 --- a/lib/Service/SocialApiService.php +++ b/lib/Service/SocialApiService.php @@ -183,12 +183,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)]; } |