From ac9496343f43104030b73863c7a47c7998a105a6 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 8 Oct 2018 12:46:51 +0200 Subject: [PATCH] fix PHP Warning: Invalid argument supplied for foreach() --- api/src/Contacts.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/api/src/Contacts.php b/api/src/Contacts.php index 9ed9418153..2737f57129 100755 --- a/api/src/Contacts.php +++ b/api/src/Contacts.php @@ -1505,12 +1505,16 @@ class Contacts extends Contacts\Storage $type = null; } $title = $this->fileas($contact,$type); - $field_list = is_string($this->prefs['link_title_cf']) ? explode(',', $this->prefs['link_title_cf']) : $this->prefs['link_title_cf']; - foreach ($field_list as $field) + + if (!empty($this->prefs['link_title_cf'])) { - if($contact['#'.$field]) + $field_list = is_string($this->prefs['link_title_cf']) ? explode(',', $this->prefs['link_title_cf']) : $this->prefs['link_title_cf']; + foreach ($field_list as $field) { - $title .= ', ' . $contact['#'.$field]; + if($contact['#'.$field]) + { + $title .= ', ' . $contact['#'.$field]; + } } } return $title ;