From 948155e96f77307a2763cd72bfbb1934b00cc8a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20St=C5=99=C3=ADbrn=C3=BD?= <35335130+kubajznik@users.noreply.github.com> Date: Tue, 14 Mar 2023 23:01:54 +0100 Subject: [PATCH] NEW No overwrite of optionals during put() When making a PUT request, only the sent fields should be changed. This should apply for optionals too. However up until now the array_options field gets changed as whole and therefore overwritten if only one optional fields gets send. --- htdocs/societe/class/api_contacts.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/class/api_contacts.class.php b/htdocs/societe/class/api_contacts.class.php index 88e9398f5fa..9d6ed42ddb1 100644 --- a/htdocs/societe/class/api_contacts.class.php +++ b/htdocs/societe/class/api_contacts.class.php @@ -326,8 +326,13 @@ class Contacts extends DolibarrApi foreach ($request_data as $field => $value) { if ($field == 'id') { continue; + } elseif ($field == 'array_options' && is_array($value)) { + foreach ($value as $index => $val) { + $this->contact->array_options[$index] = $val; + } + } else { + $this->contact->$field = $value; } - $this->contact->$field = $value; } if (isModEnabled('mailing') && !empty($this->contact->email) && isset($this->contact->no_email)) {