Clean code: No more fetch to clone

This commit is contained in:
Laurent Destailleur 2022-08-11 23:59:25 +02:00
parent 0f3ed254fd
commit 9bc6c41ca7
14 changed files with 19 additions and 25 deletions

View File

@ -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'));

View File

@ -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;

View File

@ -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) {

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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';

View File

@ -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";

View File

@ -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;

View File

@ -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;
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -149,7 +149,7 @@ if ($action == 'update' && !$cancel && $permissiontoaddbankaccount) {
{
$objectuser->fetch($id);
$objectuser->oldcopy = clone $objectuser;
$objectuser->oldcopy = dol_clone($objectuser);
$db->begin();