From b56cd11f021e76fba68d134e3a0e26985e2d7882 Mon Sep 17 00:00:00 2001 From: Lionel VESSILLER Date: Wed, 6 Mar 2019 12:00:55 +0100 Subject: [PATCH 1/3] Fix default contact id for update and clone actions in event card --- htdocs/comm/action/card.php | 8 ++++++++ htdocs/comm/action/class/actioncomm.class.php | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 8458207a5d8..6ad881d141c 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -160,6 +160,10 @@ if ($action == 'confirm_clone' && $confirm == 'yes') { if ($id > 0) { $object->fetch($id); + if (!empty($object->socpeopleassigned)) { + reset($object->socpeopleassigned); + $object->contactid = key($object->socpeopleassigned); + } $result = $object->createFromClone(GETPOST('fk_userowner'), GETPOST('socid')); if ($result > 0) { header("Location: " . $_SERVER['PHP_SELF'] . '?id=' . $result); @@ -431,6 +435,10 @@ if ($action == 'update') $object->socpeopleassigned = array(); foreach ($socpeopleassigned as $cid) $object->socpeopleassigned[$cid] = array('id' => $cid); $object->contactid = GETPOST("contactid", 'int'); + if (empty($object->contactid) && !empty($object->socpeopleassigned)) { + reset($object->socpeopleassigned); + $object->contactid = key($object->socpeopleassigned); + } $object->fk_project = GETPOST("projectid", 'int'); $object->note = GETPOST("note", "none"); // deprecated $object->note_private= GETPOST("note", "none"); diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index fba891a848a..56e5e68b2f7 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -270,7 +270,7 @@ class ActionComm extends CommonObject $this->userassigned[$tmpid]=array('id'=>$tmpid, 'transparency'=>$this->transparency); } - if (is_object($this->contact) && isset($this->contact->id) && $this->contact->id > 0 && ! ($this->contactid > 0)) $this->contactid = $this->contact->id; // For backward compatibility. Using this->contact->xx is deprecated + //if (is_object($this->contact) && isset($this->contact->id) && $this->contact->id > 0 && ! ($this->contactid > 0)) $this->contactid = $this->contact->id; // For backward compatibility. Using this->contact->xx is deprecated $userownerid=$this->userownerid; @@ -656,7 +656,7 @@ class ActionComm extends CommonObject $this->fk_project = $obj->fk_project; // To have fetch_project method working $this->societe->id = $obj->fk_soc; // deprecated - $this->contact->id = $obj->fk_contact; // deprecated + //$this->contact->id = $obj->fk_contact; // deprecated $this->fk_element = $obj->elementid; $this->elementid = $obj->elementid; @@ -867,7 +867,7 @@ class ActionComm extends CommonObject } $socid=($this->socid?$this->socid:((isset($this->societe->id) && $this->societe->id > 0) ? $this->societe->id : 0)); - $contactid=($this->contactid?$this->contactid:((isset($this->contact->id) && $this->contact->id > 0) ? $this->contact->id : 0)); + $contactid=($this->contactid?$this->contactid:0); $userownerid=($this->userownerid?$this->userownerid:0); $userdoneid=($this->userdoneid?$this->userdoneid:0); From 414bac6fb48e394cb35555a30c9e590c4d05acc2 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 6 Mar 2019 17:56:43 +0100 Subject: [PATCH 2/3] avoid logging empty query --- htdocs/core/db/mysqli.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 6c3bfd2362f..1b040ddfa18 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -256,6 +256,8 @@ class DoliDBMysqli extends DoliDB $query = trim($query); + if (empty($query)) return null; + if (! in_array($query, array('BEGIN','COMMIT','ROLLBACK'))) dol_syslog('sql='.$query, LOG_DEBUG); if (! $this->database_name) From b4bdbda9f5058eb4394cf80134ca6405439392d5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 7 Mar 2019 12:36:57 +0100 Subject: [PATCH 3/3] Update mysqli.class.php --- htdocs/core/db/mysqli.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 1b040ddfa18..1e244df883f 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -256,9 +256,8 @@ class DoliDBMysqli extends DoliDB $query = trim($query); - if (empty($query)) return null; - if (! in_array($query, array('BEGIN','COMMIT','ROLLBACK'))) dol_syslog('sql='.$query, LOG_DEBUG); + if (empty($query)) return false; // Return false = error if empty request if (! $this->database_name) {