From 81ef355b65494c0f72f060a52635cea9a7617da4 Mon Sep 17 00:00:00 2001 From: fappels Date: Wed, 6 Jun 2018 17:10:46 +0200 Subject: [PATCH 1/3] Fix trigger on setValueFrom Load updated values into object for trigger. --- htdocs/core/class/commonobject.class.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d98fcfc4717..510248b7c2c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1457,7 +1457,16 @@ abstract class CommonObject { if ($trigkey) { - $result=$this->call_trigger($trigkey, (! empty($fuser) && is_object($fuser)) ? $fuser : $user); // This may set this->errors + // call trigger with updated object values + if (empty($this->get_field_list()) && method_exists($this, 'fetch')) + { + $result = $this->fetch($id); + } + else + { + $result = $this->fetchCommon($id); + } + if ($result >= 0) $result=$this->call_trigger($trigkey, (! empty($fuser) && is_object($fuser)) ? $fuser : $user); // This may set this->errors if ($result < 0) $error++; } From 141d19571cc2e656ac4ad88e80ab7cdd2876c975 Mon Sep 17 00:00:00 2001 From: fappels Date: Wed, 6 Jun 2018 17:11:34 +0200 Subject: [PATCH 2/3] Add modify trigger to barcode modify. --- htdocs/product/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 34df9ae725c..03cfbc7f841 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -167,7 +167,7 @@ if (empty($reshook)) if ($result >= 0) { - $result = $object->setValueFrom('barcode', GETPOST('barcode')); + $result = $object->setValueFrom('barcode', GETPOST('barcode'), '', null, 'text', '', $user, 'PRODUCT_MODIFY'); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } From a9f60bcdacc8b3866a47a7da5fc5f23f030de779 Mon Sep 17 00:00:00 2001 From: fappels Date: Wed, 6 Jun 2018 22:04:12 +0200 Subject: [PATCH 3/3] fix travis --- htdocs/core/class/commonobject.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 510248b7c2c..1ff1ed6b2d6 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1458,9 +1458,9 @@ abstract class CommonObject if ($trigkey) { // call trigger with updated object values - if (empty($this->get_field_list()) && method_exists($this, 'fetch')) + if (empty($this->fields) && method_exists($this, 'fetch')) { - $result = $this->fetch($id); + $result = $this->fetch($id); } else {