diff --git a/include/class.ticket.php b/include/class.ticket.php index f32cfbd86d8f12eccb000c4707b54d159b068991..da868d7526e601a5d41004065248e9c7498f12b4 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -1670,12 +1670,15 @@ class Ticket { function delete() { + //delete just orphaned ticket thread & associated attachments. + // Fetch thread prior to removing ticket entry + $t = $this->getThread(); + $sql = 'DELETE FROM '.TICKET_TABLE.' WHERE ticket_id='.$this->getId().' LIMIT 1'; if(!db_query($sql) || !db_affected_rows()) return false; - //delete just orphaned ticket thread & associated attachments. - $this->getThread()->delete(); + $t->delete(); foreach (DynamicFormEntry::forTicket($this->getId()) as $form) $form->delete();