From d113cf3689ad3a579c0d723c42329bfaeff27617 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Fri, 12 Aug 2022 09:20:18 +0200 Subject: [PATCH] Ticket `oldcopy`: use dol_clone() instead of fetching; keep oldcopy up to date if the methods are called several times --- htdocs/ticket/class/ticket.class.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 95c60480cfa..f6a4773c58f 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -870,9 +870,8 @@ class Ticket extends CommonObject global $conf, $langs, $hookmanager; $error = 0; - if (empty($this->oldcopy) && empty($notrigger)) { - $this->oldcopy = new self($this->db); - $this->oldcopy->fetch($this->id); + if (empty($notrigger)) { + $this->oldcopy = dol_clone($this, 1); } // Clean parameters @@ -1464,9 +1463,8 @@ class Ticket extends CommonObject $error = 0; if ($this->statut != self::STATUS_CANCELED) { // no closed - if (empty($this->oldcopy) && empty($notrigger)) { - $this->oldcopy = new self($this->db); - $this->oldcopy->fetch($this->id); + if (empty($notrigger)) { + $this->oldcopy = dol_clone($this, 1); } $this->db->begin();