From e247ec162ac896bac25fa30c30046f5ef6c4fe94 Mon Sep 17 00:00:00 2001 From: atm-florian Date: Thu, 11 Aug 2022 15:23:53 +0200 Subject: [PATCH] oldcopy for TICKET_MODIFY: fetch the old ticket before the UPDATE query --- htdocs/ticket/class/ticket.class.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index d88fc15ade4..95c60480cfa 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -870,6 +870,11 @@ 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); + } + // Clean parameters if (isset($this->ref)) { $this->ref = trim($this->ref); @@ -979,10 +984,6 @@ class Ticket extends CommonObject if (!$error && !$notrigger) { // Call trigger - if (empty($this->oldcopy)) { - $this->oldcopy = new self($this->db); - $this->oldcopy->fetch($this->id); - } $result = $this->call_trigger('TICKET_MODIFY', $user); if ($result < 0) { $error++; @@ -1463,6 +1464,10 @@ 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); + } $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."ticket";