diff options
author | Thomas Citharel <tcit@tcit.fr> | 2022-07-27 08:55:16 +0200 |
---|---|---|
committer | Thomas Citharel <tcit@tcit.fr> | 2022-10-19 15:01:07 +0200 |
commit | 17f8fbdda82754ab31e63f1d140f93655b57f630 (patch) | |
tree | 79b22c35de0187f3c2481043b1f9b794c20fb241 | |
parent | eb035630e2ca67195da30371c0403e6873c64d8c (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 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)]; } |