diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index f7b900feaa4..43747513c96 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -278,7 +278,7 @@ if (empty($reshook)) { } // Create new object if ($result > 0 && !$error) { - $object->oldcopy = clone $object; + $object->oldcopy = dol_clone($object); // Change values $object->civility_id = trim(GETPOST("civility_id", 'alphanohtml')); diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index f3d5f96a78a..e37d52480fa 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -170,7 +170,8 @@ if ($action == 'add' && $user->rights->adherent->configurer) { if ($action == 'update' && $user->rights->adherent->configurer) { $object->fetch($rowid); - $object->oldcopy = clone $object; + $object->oldcopy = dol_clone($object); + $object->label= trim($label); $object->morphy = trim($morphy); $object->status = (int) $status; diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 6f97b3f134d..6dd6cd5663b 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -677,7 +677,7 @@ if (empty($reshook) && $action == 'update') { $object->fetch($id); $object->fetch_optionals(); $object->fetch_userassigned(); - $object->oldcopy = clone $object; + $object->oldcopy = dol_clone($object); // Clean parameters if ($fulldayevent) { @@ -927,7 +927,7 @@ if (empty($reshook) && $action == 'confirm_delete' && GETPOST("confirm") == 'yes $object->fetch($id); $object->fetch_optionals(); $object->fetch_userassigned(); - $object->oldcopy = clone $object; + $object->oldcopy = dol_clone($object); if ($user->rights->agenda->myactions->delete || $user->rights->agenda->allactions->delete) { diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 2afad30c454..c60f10be857 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -212,7 +212,7 @@ if (GETPOST("viewperuser", 'alpha') || $mode == 'show_peruser') { $event->fetch($actionid); $event->fetch_optionals(); $event->fetch_userassigned(); - $event->oldcopy = clone $event; + $event->oldcopy = dol_clone($event); $result = $event->delete(); } diff --git a/htdocs/comm/action/pertype.php b/htdocs/comm/action/pertype.php index 85eb355f2b6..d21b20bbfaf 100644 --- a/htdocs/comm/action/pertype.php +++ b/htdocs/comm/action/pertype.php @@ -189,7 +189,7 @@ if ($action == 'delete_action' && $user->rights->agenda->delete) { $event->fetch($actionid); $event->fetch_optionals(); $event->fetch_userassigned(); - $event->oldcopy = clone $event; + $event->oldcopy = dol_clone($event); $result = $event->delete(); } diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 87def7240f5..b30ef8f7ba9 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -196,7 +196,7 @@ if ($action == 'delete_action' && $user->rights->agenda->delete) { $event->fetch($actionid); $event->fetch_optionals(); $event->fetch_userassigned(); - $event->oldcopy = clone $event; + $event->oldcopy = dol_clone($event); $result = $event->delete(); } diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index 6030fc1e6bd..aa7ba34d9f0 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -60,7 +60,7 @@ if ($action == 'update' && !GETPOST("cancel") && $user->rights->societe->contact $result = $object->update_perso($id, $user); if ($result > 0) { - $object->oldcopy = clone $object; + $object->oldcopy = dol_clone($object); // Logo/Photo save $dir = $conf->societe->dir_output.'/contact/'.get_exdir($object->id, 0, 0, 1, $object, 'contact').'/photos'; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 1e8da8a9a81..8dbcde19d0d 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -3135,8 +3135,7 @@ class ContratLigne extends CommonObjectLine $this->db->begin(); - $this->oldcopy = new ContratLigne($this->db); - $this->oldcopy->fetch($this->id); + $this->oldcopy = dol_clone($this); // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET"; diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index 937ca6f7875..960d2ac4744 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -71,19 +71,19 @@ class Comment extends CommonObject public $fk_user_modif; /** - * @var int Entity + * @var int Entity */ public $entity; /** - * @var string import key + * @var string Import key */ public $import_key; public $comments = array(); /** - * @var Comment Object oldcopy + * @var Comment Object oldcopy */ public $oldcopy; diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 029c5651a32..b832bceb822 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -533,7 +533,7 @@ class Fichinter extends CommonObject $resql = $this->db->query($sql); if ($resql) { if (!$error) { - $this->oldcopy = clone $this; + $this->oldcopy = dol_clone($this); } if (!$error) { @@ -1422,7 +1422,7 @@ class Fichinter extends CommonObject } if (!$error) { - $this->oldcopy = clone $this; + $this->oldcopy = dol_clone($this); $this->ref_client = $ref_client; } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index fde8c453a2e..28ddb32624b 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1051,9 +1051,7 @@ class Product extends CommonObject if ($result >= 0) { if (empty($this->oldcopy)) { - $org = new self($this->db); - $org->fetch($this->id); - $this->oldcopy = $org; + $this->oldcopy = dol_clone($this); } // Test if batch management is activated on existing product diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 0e0f8883f99..3b169055bfa 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -388,9 +388,7 @@ class Productlot extends CommonObject // Put here code to add a control on parameters values if (empty($this->oldcopy)) { - $org = new self($this->db); - $org->fetch($this->id); - $this->oldcopy = $org; + $this->oldcopy = dol_clone($this); } // Update request diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index da99b2f2e97..2188d3b0a23 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -263,9 +263,7 @@ class Dolresource extends CommonObject } if (empty($this->oldcopy)) { - $org = new self($this->db); - $org->fetch($this->id); - $this->oldcopy = $org; + $this->oldcopy = dol_clone($this); } // Update request diff --git a/htdocs/user/bank.php b/htdocs/user/bank.php index 6be5afb3753..edae0a6a89a 100644 --- a/htdocs/user/bank.php +++ b/htdocs/user/bank.php @@ -149,7 +149,7 @@ if ($action == 'update' && !$cancel && $permissiontoaddbankaccount) { { $objectuser->fetch($id); - $objectuser->oldcopy = clone $objectuser; + $objectuser->oldcopy = dol_clone($objectuser); $db->begin();