From 3a78357253376ec042c590e4dcf3fd2a3eb432dc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 29 Nov 2023 16:18:34 +0100 Subject: [PATCH] Try an implementation a fix to avoid infinite loop in sync api - trigger --- htdocs/societe/class/api_thirdparties.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 2ff41fec54a..43ca888681f 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -263,8 +263,14 @@ class Thirdparties extends DolibarrApi $result = $this->_validate($request_data); foreach ($request_data as $field => $value) { + if ($field === 'caller') { + // Add a mention of caller so on trigger called after action, we can filter to avoid a loop if we try to sync back again whith the caller + $this->company->context['caller'] = $request_data['caller']; + continue; + } $this->company->$field = $value; } + if ($this->company->create(DolibarrApiAccess::$user) < 0) { throw new RestException(500, 'Error creating thirdparty', array_merge(array($this->company->error), $this->company->errors)); }