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:31:26 +0000 |
commit | 4ba8c5acd150f5fd5e8d2eba77dfa67065ab569b (patch) | |
tree | 1e5f7654e2f1b76e3cda880187a2458db2fae50e | |
parent | c80455899343bd5ee2530fea4e7c27350eba43c7 (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)]; } |