From 08009bcec50dee3665e805145418750540cab400 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 18 Jan 2022 10:06:11 +0100 Subject: [PATCH 1/2] FIX avoid warning --- htdocs/core/class/commonobject.class.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 029ac6cbfc1..39dc97cf930 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1215,17 +1215,20 @@ abstract class CommonObject public function delete_linked_contact($source = '', $code = '') { // phpcs:enable + $listId = null; $temp = array(); $typeContact = $this->liste_type_contact($source, '', 0, 0, $code); - foreach ($typeContact as $key => $value) { - array_push($temp, $key); + if (!empty($typeContact)) { + foreach ($typeContact as $key => $value) { + array_push($temp, $key); + } + $listId = implode(",", $temp); } - $listId = implode(",", $temp); $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact"; $sql .= " WHERE element_id = ".((int) $this->id); - if ($listId) { + if (!empty($listId)) { $sql .= " AND fk_c_type_contact IN (".$this->db->sanitize($listId).")"; } From 9dd3d970bfdef67e822e68c74e1f7335ad54a27a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 23 Jan 2022 12:31:30 +0100 Subject: [PATCH 2/2] Update commonobject.class.php --- htdocs/core/class/commonobject.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 39dc97cf930..db004c117a0 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1215,7 +1215,7 @@ abstract class CommonObject public function delete_linked_contact($source = '', $code = '') { // phpcs:enable - $listId = null; + $listId = ''; $temp = array(); $typeContact = $this->liste_type_contact($source, '', 0, 0, $code);