From b1a7c23daa560aab3bb9362946e21d591a983764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Champlon?= Date: Wed, 1 Feb 2023 11:20:44 +0100 Subject: [PATCH 1/3] fix updateExtrafield option key empty set null --- 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 9fa15da550c..ae2acb36d7f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6350,7 +6350,7 @@ abstract class CommonObject } if ($linealreadyfound) { - if ($this->array_options["options_".$key] === null) { + if ($this->array_options["options_".$key] === null || $this->array_options["options_".$key] === "") { $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key." = null"; } else { $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key." = '".$this->db->escape($this->array_options["options_".$key])."'"; From aa60bd29c1c309f1a6fe2fab14f12612e94e5256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Champlon?= Date: Mon, 20 Feb 2023 16:39:03 +0100 Subject: [PATCH 2/3] check link empty in switch --- htdocs/core/class/commonobject.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ae2acb36d7f..a10c649b6e2 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6304,6 +6304,11 @@ abstract class CommonObject $this->array_options["options_".$key] = null; } break; + case 'link': + if ($this->array_options["options_".$key] === '') { + $this->array_options["options_".$key] = null; + } + break; /* case 'link': $param_list = array_keys($attributeParam['options']); @@ -6350,7 +6355,7 @@ abstract class CommonObject } if ($linealreadyfound) { - if ($this->array_options["options_".$key] === null || $this->array_options["options_".$key] === "") { + if ($this->array_options["options_".$key] === null) { $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key." = null"; } else { $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key." = '".$this->db->escape($this->array_options["options_".$key])."'"; From baa28e175da73879d0cc3b14e76aca389efa1e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Champlon?= Date: Mon, 20 Feb 2023 16:47:01 +0100 Subject: [PATCH 3/3] indent --- 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 a10c649b6e2..58a057834f8 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6307,7 +6307,7 @@ abstract class CommonObject case 'link': if ($this->array_options["options_".$key] === '') { $this->array_options["options_".$key] = null; - } + } break; /* case 'link':