diff --git a/src/messenger/tests/server_side/webim/libs/classes/ThreadTest.php b/src/messenger/tests/server_side/webim/libs/classes/ThreadTest.php index 8697cdc0..35848329 100644 --- a/src/messenger/tests/server_side/webim/libs/classes/ThreadTest.php +++ b/src/messenger/tests/server_side/webim/libs/classes/ThreadTest.php @@ -298,7 +298,6 @@ class ThreadTest extends PHPUnit_Framework_TestCase { $thread = Thread::create(); // Update thread values - $thread->lastRevision = $last_revision = 10; $thread->state = $state = Thread::STATE_CHATTING; $thread->lastToken = $last_token = 11; @@ -309,7 +308,6 @@ class ThreadTest extends PHPUnit_Framework_TestCase { $thread->messageCount = $message_count = 15; $thread->created = $created = time() - 200; - $thread->modified = $modified = time() - 190; $thread->chatStarted = $chat_started = time() - 180; $thread->agentId = $agent_id = 16; @@ -336,7 +334,6 @@ class ThreadTest extends PHPUnit_Framework_TestCase { $thread_info = $this->_helper_getThreadInfo($thread->id); // Check values - $this->assertEquals($thread_info['lrevision'],$last_revision); $this->assertEquals($thread_info['istate'], $state); $this->assertEquals($thread_info['ltoken'], $last_token); @@ -347,7 +344,6 @@ class ThreadTest extends PHPUnit_Framework_TestCase { $this->assertEquals($thread_info['messageCount'], $message_count); $this->assertEquals($thread_info['dtmcreated'], $created); - $this->assertEquals($thread_info['dtmmodified'], $modified); $this->assertEquals($thread_info['dtmchatstarted'], $chat_started); $this->assertEquals($thread_info['agentId'], $agent_id); diff --git a/src/messenger/webim/libs/classes/thread.php b/src/messenger/webim/libs/classes/thread.php index 7e947575..b534a043 100644 --- a/src/messenger/webim/libs/classes/thread.php +++ b/src/messenger/webim/libs/classes/thread.php @@ -526,28 +526,31 @@ Class Thread { } } - $this->save(); + $this->save(false); } /** * Save the thread to the database + * + * @param boolean $update_revision Indicates if last modified time and last revision should be updated */ - public function save(){ + public function save($update_revision = true){ $db = Database::getInstance(); - $query = "update {chatthread} t " . - "set lrevision = ?, dtmmodified = ?"; + // Update modified time and last revision if need + if ($update_revision) { + $this->lastRevision = $this->nextRevision(); + $this->modified = time(); + } $values = array(); - $values[] = $this->nextRevision(); - $values[] = time(); - + $set_clause = array(); foreach ($this->updatedFields as $field_name) { - $query .= ", {$field_name} = ?" ; + $set_clause[] = "{$field_name} = ?"; $values[] = $this->threadInfo[$field_name]; } - $query .= " where threadid = ?"; + $query = "update {chatthread} t set " . implode(', ', $set_clause) . " where threadid = ?"; $values[] = $this->id; $db->query($query, $values); }