diff options
author | Thomas Citharel <tcit@tcit.fr> | 2022-07-27 08:55:16 +0200 |
---|---|---|
committer | backportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com> | 2022-10-19 14:18:32 +0000 |
commit | b2a3d2493244a85ca5f8813979461f3a70da2d27 (patch) | |
tree | 251124c07904c03fb656b35436bf246345bd4146 | |
parent | cc41cfb3ddcda7e0581255746e00441b5590bea1 (diff) |
Avoid Undefined offset: 0 error by testing if the element exists before accessing it
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
-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)]; } |