From 1a956cce9a1524a9fb502a72cda8b2e2c3841952 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 1 Sep 2017 10:31:22 +0200 Subject: [PATCH 1/3] Fix : insert line extrafield --- htdocs/core/class/commonobject.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4b6c1263026..bd1f6198a95 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4156,6 +4156,10 @@ abstract class CommonObject foreach($this->array_options as $key => $value) { $attributeKey = substr($key,8); // Remove 'options_' prefix + + // array_option may contain extrafields from an origin object that doesn't exist in current object, we should not try to insert them + if(empty($extrafields->attribute_type[$attributeKey])) continue; + $attributeType = $extrafields->attribute_type[$attributeKey]; $attributeLabel = $extrafields->attribute_label[$attributeKey]; $attributeParam = $extrafields->attribute_param[$attributeKey]; From cf49c274a642c721ef6074127ba8369f95e2363b Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 1 Sep 2017 10:38:50 +0200 Subject: [PATCH 2/3] Better fix --- htdocs/core/class/commonobject.class.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index bd1f6198a95..fed6ef1df3d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4156,9 +4156,12 @@ abstract class CommonObject foreach($this->array_options as $key => $value) { $attributeKey = substr($key,8); // Remove 'options_' prefix - - // array_option may contain extrafields from an origin object that doesn't exist in current object, we should not try to insert them - if(empty($extrafields->attribute_type[$attributeKey])) continue; + + // array_option may contain extrafields from an origin object that doesn't exist in current object, we should not try to insert them + if(empty($extrafields->attribute_type[$attributeKey])) { + unset($this->array_options[$key]); + continue; + } $attributeType = $extrafields->attribute_type[$attributeKey]; $attributeLabel = $extrafields->attribute_label[$attributeKey]; From 61ee071f438ce022fd45e103c3e4f421038ab2ab Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Sep 2017 10:17:51 +0200 Subject: [PATCH 3/3] Fix regression --- htdocs/core/class/commonobject.class.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9bc53a46b19..16450fd9feb 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4261,13 +4261,6 @@ abstract class CommonObject foreach($new_array_options as $key => $value) { $attributeKey = substr($key,8); // Remove 'options_' prefix - - // array_option may contain extrafields from an origin object that doesn't exist in current object, we should not try to insert them - if(empty($extrafields->attribute_type[$attributeKey])) { - unset($this->array_options[$key]); - continue; - } - $attributeType = $extrafields->attribute_type[$attributeKey]; $attributeLabel = $extrafields->attribute_label[$attributeKey]; $attributeParam = $extrafields->attribute_param[$attributeKey];