2
0
forked from Wavyzz/dolibarr

[Qual] Replaced deprecated dol_clone by native clone

This commit is contained in:
Raphaël Doursenaud
2015-09-24 16:32:48 +02:00
parent ea7384cf68
commit 9f2545b95d
33 changed files with 48 additions and 47 deletions

View File

@@ -211,7 +211,7 @@ abstract class ActionsAdherentCardCommon
{ {
$this->object->fetch($_POST["adherentid"]); $this->object->fetch($_POST["adherentid"]);
$this->object->oldcopy=dol_clone($this->object); $this->object->oldcopy = clone $this->object;
$this->assign_post(); $this->assign_post();
@@ -434,4 +434,3 @@ abstract class ActionsAdherentCardCommon
} }
} }

View File

@@ -268,7 +268,7 @@ if (empty($reshook))
// Create new object // Create new object
if ($result > 0 && ! $error) if ($result > 0 && ! $error)
{ {
$object->oldcopy=dol_clone($object); $object->oldcopy = clone $object;
// Change values // Change values
$object->civility_id = trim($_POST["civility_id"]); $object->civility_id = trim($_POST["civility_id"]);

View File

@@ -410,7 +410,7 @@ class ActionComm extends CommonObject
$this->db->begin(); $this->db->begin();
// Load source object // Load source object
$objFrom = dol_clone($this); $objFrom = clone $this;
$this->fetch_optionals(); $this->fetch_optionals();
$this->fetch_userassigned(); $this->fetch_userassigned();

View File

@@ -951,7 +951,7 @@ class AskPriceSupplier extends CommonObject
$line->fetch_optionals($line->rowid); $line->fetch_optionals($line->rowid);
// Load source object // Load source object
$objFrom = dol_clone($this); $objFrom = clone $this;
$objsoc=new Societe($this->db); $objsoc=new Societe($this->db);

View File

@@ -1077,7 +1077,7 @@ class Propal extends CommonObject
$line->fetch_optionals($line->rowid); $line->fetch_optionals($line->rowid);
// Load source object // Load source object
$objFrom = dol_clone($this); $objFrom = clone $this;
$objsoc=new Societe($this->db); $objsoc=new Societe($this->db);

View File

@@ -129,7 +129,7 @@ if (empty($reshook))
if ($object->id > 0) if ($object->id > 0)
{ {
// Because createFromClone modifies the object, we must clone it so that we can restore it later // Because createFromClone modifies the object, we must clone it so that we can restore it later
$orig = dol_clone($object); $orig = clone $object;
$result=$object->createFromClone($socid); $result=$object->createFromClone($socid);
if ($result > 0) if ($result > 0)

View File

@@ -958,7 +958,7 @@ class Commande extends CommonOrder
$line->fetch_optionals($line->rowid); $line->fetch_optionals($line->rowid);
// Load source object // Load source object
$objFrom = dol_clone($this); $objFrom = clone $this;
// Change socid if needed // Change socid if needed
if (! empty($socid) && $socid != $this->socid) if (! empty($socid) && $socid != $this->socid)

View File

@@ -701,7 +701,7 @@ class Facture extends CommonInvoice
$line->fetch_optionals($line->rowid); $line->fetch_optionals($line->rowid);
// Load source object // Load source object
$objFrom = dol_clone($this); $objFrom = clone $this;

View File

@@ -207,7 +207,7 @@ abstract class ActionsContactCardCommon
{ {
$this->object->fetch($_POST["contactid"]); $this->object->fetch($_POST["contactid"]);
$this->object->oldcopy=dol_clone($this->object); $this->object->oldcopy = clone $this->object;
$this->assign_post(); $this->assign_post();

View File

@@ -289,7 +289,7 @@ if (empty($reshook))
$object->fetch($contactid); $object->fetch($contactid);
$object->oldcopy=dol_clone($object); $object->oldcopy = clone$object;
$object->old_lastname = GETPOST("old_lastname"); $object->old_lastname = GETPOST("old_lastname");
$object->old_firstname = GETPOST("old_firstname"); $object->old_firstname = GETPOST("old_firstname");

View File

@@ -125,7 +125,7 @@ class FileUpload
if (!empty($parent->socid)) { if (!empty($parent->socid)) {
$parent->fetch_thirdparty(); $parent->fetch_thirdparty();
} }
$object->$parentObject = dol_clone($parent); $object->$parentObject = clone $parent;
} else { } else {
$object->fetch_thirdparty(); $object->fetch_thirdparty();
} }

View File

@@ -1083,7 +1083,9 @@ class FormFile
} }
} }
if ($result > 0) { $found=1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref]=dol_clone($object_instance); } // Save object into a cache if ($result > 0) { // Save object into a cache
$found=1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref] = clone $object_instance;
}
if ($result == 0) { $found=1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref]='notfound'; unset($filearray[$key]); } if ($result == 0) { $found=1; $this->cache_objects[$modulepart.'_'.$id.'_'.$ref]='notfound'; unset($filearray[$key]); }
} }

View File

@@ -397,7 +397,7 @@ function dol_clone($object)
{ {
dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING); dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING);
$myclone=clone($object); $myclone = clone $object;
return $myclone; return $myclone;
} }

View File

@@ -99,7 +99,7 @@ class MenuManager
if ($mode == 'jmobile') if ($mode == 'jmobile')
{ {
$this->topmenu=dol_clone($this->menu); $this->topmenu = clone $this->menu;
unset($this->menu->liste); unset($this->menu->liste);
} }
} }
@@ -205,7 +205,7 @@ class MenuManager
if ($mode == 'jmobile') if ($mode == 'jmobile')
{ {
$this->leftmenu=dol_clone($this->menu); $this->leftmenu = clone $this->menu;
unset($this->menu->liste); unset($this->menu->liste);
} }
} }

View File

@@ -89,7 +89,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
if (empty($object->oldcopy) || ! is_object($object->oldcopy)) if (empty($object->oldcopy) || ! is_object($object->oldcopy))
{ {
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING); dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
$object->oldcopy=dol_clone($object); $object->oldcopy = clone $object;
} }
$oldinfo=$object->oldcopy->_load_ldap_info(); $oldinfo=$object->oldcopy->_load_ldap_info();
@@ -126,7 +126,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
if (empty($object->oldcopy) || ! is_object($object->oldcopy)) if (empty($object->oldcopy) || ! is_object($object->oldcopy))
{ {
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING); dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
$object->oldcopy=dol_clone($object); $object->oldcopy = clone $object;
} }
$oldinfo=$object->oldcopy->_load_ldap_info(); $oldinfo=$object->oldcopy->_load_ldap_info();
@@ -287,7 +287,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
if (empty($object->oldcopy) || ! is_object($object->oldcopy)) if (empty($object->oldcopy) || ! is_object($object->oldcopy))
{ {
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING); dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
$object->oldcopy=dol_clone($object); $object->oldcopy = clone $object;
} }
$oldinfo=$object->oldcopy->_load_ldap_info(); $oldinfo=$object->oldcopy->_load_ldap_info();
@@ -364,7 +364,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
if (empty($object->oldcopy) || ! is_object($object->oldcopy)) if (empty($object->oldcopy) || ! is_object($object->oldcopy))
{ {
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING); dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
$object->oldcopy=dol_clone($object); $object->oldcopy = clone $object;
} }
$oldinfo=$object->oldcopy->_load_ldap_info(); $oldinfo=$object->oldcopy->_load_ldap_info();
@@ -493,7 +493,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers
if (empty($object->oldcopy) || ! is_object($object->oldcopy)) if (empty($object->oldcopy) || ! is_object($object->oldcopy))
{ {
dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING); dol_syslog("Trigger ".$action." was called by a function that did not set previously the property ->oldcopy onto object", LOG_WARNING);
$object->oldcopy=dol_clone($object); $object->oldcopy = clone $object;
} }
$oldinfo=$object->oldcopy->_load_ldap_info(); $oldinfo=$object->oldcopy->_load_ldap_info();

View File

@@ -556,7 +556,7 @@ class Export
$filename.='.'.$objmodel->getDriverExtension(); $filename.='.'.$objmodel->getDriverExtension();
$dirname=$conf->export->dir_temp.'/'.$user->id; $dirname=$conf->export->dir_temp.'/'.$user->id;
$outputlangs=dol_clone($langs); // We clone to have an object we can modify (for example to change output charset by csv handler) without changing original value $outputlangs = clone $langs; // We clone to have an object we can modify (for example to change output charset by csv handler) without changing original value
// Open file // Open file
dol_mkdir($dirname); dol_mkdir($dirname);

View File

@@ -1138,7 +1138,7 @@ class CommandeFournisseur extends CommonOrder
$this->db->begin(); $this->db->begin();
// Load source object // Load source object
$objFrom = dol_clone($this); $objFrom = clone $this;
$this->id=0; $this->id=0;
$this->statut=0; $this->statut=0;

View File

@@ -315,7 +315,7 @@ if (empty($reshook))
{ {
if ($object->id > 0) if ($object->id > 0)
{ {
$object->oldcopy=dol_clone($object); $object->oldcopy= clone $object;
$object->ref = $ref; $object->ref = $ref;
$object->label = GETPOST('label'); $object->label = GETPOST('label');

View File

@@ -399,7 +399,7 @@ if ($id || $ref)
// We don't have supplier, so we try to guess. // We don't have supplier, so we try to guess.
// For this we build a fictive supplier with same properties than user but using vat) // For this we build a fictive supplier with same properties than user but using vat)
$mysoc2=dol_clone($mysoc); $mysoc2 = clone $mysoc;
$mysoc2->name='Fictive seller with same country'; $mysoc2->name='Fictive seller with same country';
$mysoc2->tva_assuj=1; $mysoc2->tva_assuj=1;
$default_vat=get_default_tva($mysoc2, $mysoc, $product->id, 0); $default_vat=get_default_tva($mysoc2, $mysoc, $product->id, 0);

View File

@@ -433,7 +433,7 @@ class MouvementStock extends CommonObject
// Create movement for each subproduct // Create movement for each subproduct
foreach($pids as $key => $value) foreach($pids as $key => $value)
{ {
$tmpmove = dol_clone($this); $tmpmove = clone $this;
$tmpmove->_create($user, $pids[$key], $entrepot_id, ($qty * $pqtys[$key]), $type, 0, $label, $inventorycode); // This will also call _createSubProduct making this recursive $tmpmove->_create($user, $pids[$key], $entrepot_id, ($qty * $pqtys[$key]), $type, 0, $label, $inventorycode); // This will also call _createSubProduct making this recursive
unset($tmpmove); unset($tmpmove);
} }

View File

@@ -218,7 +218,7 @@ if (empty($reshook))
if (! $error) if (! $error)
{ {
$object->oldcopy = dol_clone($object); $object->oldcopy = clone $object;
$old_start_date = $object->date_start; $old_start_date = $object->date_start;

View File

@@ -176,7 +176,7 @@ if ($id > 0 || ! empty($ref))
$result=$projectstatic->fetch($object->fk_project); $result=$projectstatic->fetch($object->fk_project);
if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
$object->project = dol_clone($projectstatic); $object->project = clone $projectstatic;
$userWrite = $projectstatic->restrictedProjectArea($user,'write'); $userWrite = $projectstatic->restrictedProjectArea($user,'write');

View File

@@ -98,7 +98,7 @@ if ($id > 0 || ! empty($ref))
$projectstatic->fetch_thirdparty(); $projectstatic->fetch_thirdparty();
} }
$object->project = dol_clone($projectstatic); $object->project = clone $projectstatic;
$upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($projectstatic->ref).'/'.dol_sanitizeFileName($object->ref); $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($projectstatic->ref).'/'.dol_sanitizeFileName($object->ref);
} }

View File

@@ -53,7 +53,7 @@ if ($id > 0 || ! empty($ref))
$projectstatic->fetch($object->fk_project); $projectstatic->fetch($object->fk_project);
if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
$object->project = dol_clone($projectstatic); $object->project = clone $projectstatic;
} }
else else
{ {

View File

@@ -205,7 +205,7 @@ if ($id > 0 || ! empty($ref))
$result=$projectstatic->fetch($object->fk_project); $result=$projectstatic->fetch($object->fk_project);
if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
$object->project = dol_clone($projectstatic); $object->project = clone $projectstatic;
$userWrite = $projectstatic->restrictedProjectArea($user,'write'); $userWrite = $projectstatic->restrictedProjectArea($user,'write');

View File

@@ -215,7 +215,7 @@ if ($id > 0 || ! empty($ref))
$result=$projectstatic->fetch($object->fk_project); $result=$projectstatic->fetch($object->fk_project);
if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty(); if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
$object->project = dol_clone($projectstatic); $object->project = clone $projectstatic;
$userWrite = $projectstatic->restrictedProjectArea($user,'write'); $userWrite = $projectstatic->restrictedProjectArea($user,'write');

View File

@@ -279,7 +279,7 @@ abstract class ActionsCardCommon
exit; exit;
} }
$oldsoccanvas = dol_clone($this->object); $oldsoccanvas = clone $this->object;
// To avoid setting code if third party is not concerned. But if it had values, we keep them. // To avoid setting code if third party is not concerned. But if it had values, we keep them.
if (empty($this->object->client) && empty($oldsoccanvas->code_client)) $this->object->code_client=''; if (empty($this->object->client) && empty($oldsoccanvas->code_client)) $this->object->code_client='';

View File

@@ -232,7 +232,7 @@ if (empty($reshook))
if ($action == 'update') if ($action == 'update')
{ {
$ret=$object->fetch($socid); $ret=$object->fetch($socid);
$object->oldcopy=dol_clone($object); $object->oldcopy = clone $object;
} }
else $object->canvas=$canvas; else $object->canvas=$canvas;
@@ -1329,7 +1329,7 @@ else
$prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed(); $prefixSupplierIsUsed = $modCodeFournisseur->verif_prefixIsUsed();
} }
$object->oldcopy=dol_clone($object); $object->oldcopy = clone $object;
if (GETPOST('name')) if (GETPOST('name'))
{ {

View File

@@ -278,7 +278,7 @@ if (($action == 'addgroup' || $action == 'removegroup') && $caneditfield)
{ {
$editgroup = new UserGroup($db); $editgroup = new UserGroup($db);
$editgroup->fetch($group); $editgroup->fetch($group);
$editgroup->oldcopy=clone($editgroup); $editgroup->oldcopy=clone $editgroup;
$object->fetch($id); $object->fetch($id);
if ($action == 'addgroup') $object->SetInGroup($group,($conf->multicompany->transverse_mode?GETPOST("entity"):$editgroup->entity)); if ($action == 'addgroup') $object->SetInGroup($group,($conf->multicompany->transverse_mode?GETPOST("entity"):$editgroup->entity));
@@ -340,7 +340,7 @@ if ($action == 'update' && ! $_POST["cancel"])
{ {
$db->begin(); $db->begin();
$object->oldcopy=clone($object); $object->oldcopy = clone $object;
$object->lastname = GETPOST("lastname",'alpha'); $object->lastname = GETPOST("lastname",'alpha');
$object->firstname = GETPOST("firstname",'alpha'); $object->firstname = GETPOST("firstname",'alpha');
@@ -508,7 +508,7 @@ if ($action == 'update' && ! $_POST["cancel"])
{ {
$object->fetch($id); $object->fetch($id);
$object->oldcopy=clone($object); $object->oldcopy = clone $object;
$ret=$object->setPassword($user,$_POST["password"]); $ret=$object->setPassword($user,$_POST["password"]);
if ($ret < 0) if ($ret < 0)

View File

@@ -1409,7 +1409,7 @@ class User extends CommonObject
// Mise a jour // Mise a jour
if (! $changelater) if (! $changelater)
{ {
if (! is_object($this->oldcopy)) $this->oldcopy=dol_clone($this); if (! is_object($this->oldcopy)) $this->oldcopy = clone $this;
$this->db->begin(); $this->db->begin();

View File

@@ -142,7 +142,7 @@ if ($action == 'adduser' || $action =='removeuser')
if ($userid) if ($userid)
{ {
$object->fetch($id); $object->fetch($id);
$object->oldcopy=dol_clone($object); $object->oldcopy = clone $object;
$edituser = new User($db); $edituser = new User($db);
$edituser->fetch($userid); $edituser->fetch($userid);
@@ -176,7 +176,7 @@ if ($action == 'update')
$object->fetch($id); $object->fetch($id);
$object->oldcopy=dol_clone($object); $object->oldcopy = clone $object;
$object->name = trim($_POST["group"]); $object->name = trim($_POST["group"]);
$object->nom = $object->name; // For backward compatibility $object->nom = $object->name; // For backward compatibility

View File

@@ -189,7 +189,7 @@ class ContactTest extends PHPUnit_Framework_TestCase
$langs=$this->savlangs; $langs=$this->savlangs;
$db=$this->savdb; $db=$this->savdb;
$localobject->oldcopy=dol_clone($localobject); $localobject->oldcopy = clone $localobject;
$localobject->note_private='New private note after update'; $localobject->note_private='New private note after update';
$localobject->note_public='New public note after update'; $localobject->note_public='New public note after update';

View File

@@ -183,7 +183,7 @@ class HolidayTest extends PHPUnit_Framework_TestCase
$langs=$this->savlangs; $langs=$this->savlangs;
$db=$this->savdb; $db=$this->savdb;
$localobject->oldcopy=dol_clone($localobject); $localobject->oldcopy = clone $localobject;
$localobject->note_private='New private note after update'; $localobject->note_private='New private note after update';
$localobject->note_public='New public note after update'; $localobject->note_public='New public note after update';