From ed5c5716bbc7cc52bc6a158f79e18dfdea702ab8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Aug 2023 15:37:17 +0200 Subject: [PATCH] Fix regression on clone of product --- htdocs/core/actions_addupdatedelete.inc.php | 4 +++- htdocs/product/card.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index bd102f3d7bb..cf3b9268ee4 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -560,7 +560,9 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd)) if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers')) { setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } else { - $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid. + // We clone object to avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. + $objectutil = dol_clone($object, 1); + // We used native clone to keep this->db valid and allow to use later all the methods of object. //$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int')); // ... $result = $objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id)); diff --git a/htdocs/product/card.php b/htdocs/product/card.php index e25729427b1..c598615af03 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -908,7 +908,9 @@ if (empty($reshook)) { } else { if ($object->id > 0) { $error = 0; - $clone = dol_clone($object, 2); + // We clone object to avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. + $clone = dol_clone($object, 1); + // We used native clone to keep this->db valid and allow to use later all the methods of object. $clone->id = null; $clone->ref = GETPOST('clone_ref', 'alphanohtml');