From 2d1cc5ef70388dced99a0618410d71fdcdff6405 Mon Sep 17 00:00:00 2001
From: Peter Rotich <peter@enhancesoft.com>
Date: Sun, 29 Sep 2013 03:58:49 +0000
Subject: [PATCH] Support last message lookup without setting last message id.

---
 include/class.ticket.php | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/class.ticket.php b/include/class.ticket.php
index 85b7e3b38..294291f65 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -471,7 +471,11 @@ class Ticket {
     }
 
     function getLastMessage() {
-        return Message::lookup($this->getLastMsgId(), $this->getId());
+
+        if($this->getLastMsgId())
+            return Message::lookup($this->getLastMsgId(), $this->getId());
+
+        return Message::lastByTicketId($this->getId());
     }
 
     function getThread() {
-- 
GitLab