Clean code: No more fetch to clone
This commit is contained in:
parent
0f3ed254fd
commit
9bc6c41ca7
@ -278,7 +278,7 @@ if (empty($reshook)) {
|
|||||||
}
|
}
|
||||||
// Create new object
|
// Create new object
|
||||||
if ($result > 0 && !$error) {
|
if ($result > 0 && !$error) {
|
||||||
$object->oldcopy = clone $object;
|
$object->oldcopy = dol_clone($object);
|
||||||
|
|
||||||
// Change values
|
// Change values
|
||||||
$object->civility_id = trim(GETPOST("civility_id", 'alphanohtml'));
|
$object->civility_id = trim(GETPOST("civility_id", 'alphanohtml'));
|
||||||
|
|||||||
@ -170,7 +170,8 @@ if ($action == 'add' && $user->rights->adherent->configurer) {
|
|||||||
if ($action == 'update' && $user->rights->adherent->configurer) {
|
if ($action == 'update' && $user->rights->adherent->configurer) {
|
||||||
$object->fetch($rowid);
|
$object->fetch($rowid);
|
||||||
|
|
||||||
$object->oldcopy = clone $object;
|
$object->oldcopy = dol_clone($object);
|
||||||
|
|
||||||
$object->label= trim($label);
|
$object->label= trim($label);
|
||||||
$object->morphy = trim($morphy);
|
$object->morphy = trim($morphy);
|
||||||
$object->status = (int) $status;
|
$object->status = (int) $status;
|
||||||
|
|||||||
@ -677,7 +677,7 @@ if (empty($reshook) && $action == 'update') {
|
|||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$object->fetch_optionals();
|
$object->fetch_optionals();
|
||||||
$object->fetch_userassigned();
|
$object->fetch_userassigned();
|
||||||
$object->oldcopy = clone $object;
|
$object->oldcopy = dol_clone($object);
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
if ($fulldayevent) {
|
if ($fulldayevent) {
|
||||||
@ -927,7 +927,7 @@ if (empty($reshook) && $action == 'confirm_delete' && GETPOST("confirm") == 'yes
|
|||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$object->fetch_optionals();
|
$object->fetch_optionals();
|
||||||
$object->fetch_userassigned();
|
$object->fetch_userassigned();
|
||||||
$object->oldcopy = clone $object;
|
$object->oldcopy = dol_clone($object);
|
||||||
|
|
||||||
if ($user->rights->agenda->myactions->delete
|
if ($user->rights->agenda->myactions->delete
|
||||||
|| $user->rights->agenda->allactions->delete) {
|
|| $user->rights->agenda->allactions->delete) {
|
||||||
|
|||||||
@ -212,7 +212,7 @@ if (GETPOST("viewperuser", 'alpha') || $mode == 'show_peruser') {
|
|||||||
$event->fetch($actionid);
|
$event->fetch($actionid);
|
||||||
$event->fetch_optionals();
|
$event->fetch_optionals();
|
||||||
$event->fetch_userassigned();
|
$event->fetch_userassigned();
|
||||||
$event->oldcopy = clone $event;
|
$event->oldcopy = dol_clone($event);
|
||||||
|
|
||||||
$result = $event->delete();
|
$result = $event->delete();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -189,7 +189,7 @@ if ($action == 'delete_action' && $user->rights->agenda->delete) {
|
|||||||
$event->fetch($actionid);
|
$event->fetch($actionid);
|
||||||
$event->fetch_optionals();
|
$event->fetch_optionals();
|
||||||
$event->fetch_userassigned();
|
$event->fetch_userassigned();
|
||||||
$event->oldcopy = clone $event;
|
$event->oldcopy = dol_clone($event);
|
||||||
|
|
||||||
$result = $event->delete();
|
$result = $event->delete();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -196,7 +196,7 @@ if ($action == 'delete_action' && $user->rights->agenda->delete) {
|
|||||||
$event->fetch($actionid);
|
$event->fetch($actionid);
|
||||||
$event->fetch_optionals();
|
$event->fetch_optionals();
|
||||||
$event->fetch_userassigned();
|
$event->fetch_userassigned();
|
||||||
$event->oldcopy = clone $event;
|
$event->oldcopy = dol_clone($event);
|
||||||
|
|
||||||
$result = $event->delete();
|
$result = $event->delete();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,7 +60,7 @@ if ($action == 'update' && !GETPOST("cancel") && $user->rights->societe->contact
|
|||||||
|
|
||||||
$result = $object->update_perso($id, $user);
|
$result = $object->update_perso($id, $user);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
$object->oldcopy = clone $object;
|
$object->oldcopy = dol_clone($object);
|
||||||
|
|
||||||
// Logo/Photo save
|
// Logo/Photo save
|
||||||
$dir = $conf->societe->dir_output.'/contact/'.get_exdir($object->id, 0, 0, 1, $object, 'contact').'/photos';
|
$dir = $conf->societe->dir_output.'/contact/'.get_exdir($object->id, 0, 0, 1, $object, 'contact').'/photos';
|
||||||
|
|||||||
@ -3135,8 +3135,7 @@ class ContratLigne extends CommonObjectLine
|
|||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$this->oldcopy = new ContratLigne($this->db);
|
$this->oldcopy = dol_clone($this);
|
||||||
$this->oldcopy->fetch($this->id);
|
|
||||||
|
|
||||||
// Update request
|
// Update request
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET";
|
||||||
|
|||||||
@ -76,7 +76,7 @@ class Comment extends CommonObject
|
|||||||
public $entity;
|
public $entity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string import key
|
* @var string Import key
|
||||||
*/
|
*/
|
||||||
public $import_key;
|
public $import_key;
|
||||||
|
|
||||||
|
|||||||
@ -533,7 +533,7 @@ class Fichinter extends CommonObject
|
|||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql) {
|
if ($resql) {
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$this->oldcopy = clone $this;
|
$this->oldcopy = dol_clone($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
@ -1422,7 +1422,7 @@ class Fichinter extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$this->oldcopy = clone $this;
|
$this->oldcopy = dol_clone($this);
|
||||||
$this->ref_client = $ref_client;
|
$this->ref_client = $ref_client;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1051,9 +1051,7 @@ class Product extends CommonObject
|
|||||||
|
|
||||||
if ($result >= 0) {
|
if ($result >= 0) {
|
||||||
if (empty($this->oldcopy)) {
|
if (empty($this->oldcopy)) {
|
||||||
$org = new self($this->db);
|
$this->oldcopy = dol_clone($this);
|
||||||
$org->fetch($this->id);
|
|
||||||
$this->oldcopy = $org;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test if batch management is activated on existing product
|
// Test if batch management is activated on existing product
|
||||||
|
|||||||
@ -388,9 +388,7 @@ class Productlot extends CommonObject
|
|||||||
// Put here code to add a control on parameters values
|
// Put here code to add a control on parameters values
|
||||||
|
|
||||||
if (empty($this->oldcopy)) {
|
if (empty($this->oldcopy)) {
|
||||||
$org = new self($this->db);
|
$this->oldcopy = dol_clone($this);
|
||||||
$org->fetch($this->id);
|
|
||||||
$this->oldcopy = $org;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update request
|
// Update request
|
||||||
|
|||||||
@ -263,9 +263,7 @@ class Dolresource extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (empty($this->oldcopy)) {
|
if (empty($this->oldcopy)) {
|
||||||
$org = new self($this->db);
|
$this->oldcopy = dol_clone($this);
|
||||||
$org->fetch($this->id);
|
|
||||||
$this->oldcopy = $org;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update request
|
// Update request
|
||||||
|
|||||||
@ -149,7 +149,7 @@ if ($action == 'update' && !$cancel && $permissiontoaddbankaccount) {
|
|||||||
{
|
{
|
||||||
$objectuser->fetch($id);
|
$objectuser->fetch($id);
|
||||||
|
|
||||||
$objectuser->oldcopy = clone $objectuser;
|
$objectuser->oldcopy = dol_clone($objectuser);
|
||||||
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user