From 29c4cba05536b2ad8761915dcbd14ceacb901bd1 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Thu, 14 Jul 2016 08:09:26 -0500 Subject: [PATCH] thread: Fix crash processing problem attachments The ThreadEntry::normalizeFileInfo() method is called from ::create(), but before the thread entry is saved. Therefore, the ::getThread() and ::getObject() methods will likely not return a valid object for posting the thread message. --- include/class.thread.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/include/class.thread.php b/include/class.thread.php index b6fc9b5f1..b7641e492 100644 --- a/include/class.thread.php +++ b/include/class.thread.php @@ -913,9 +913,18 @@ implements TemplateVariable { _S($error_descriptions[$error])); } // No need to log the missing-file error number - if ($error != UPLOAD_ERR_NO_FILE) - $this->getThread()->getObject()->logNote( - _S('File Import Error'), $error, _S('SYSTEM'), false); + if ($error != UPLOAD_ERR_NO_FILE + && ($thread = $this->getThread()) + ) { + // Log to the thread directly, since alerts should be + // suppressed and this is defintely a system message + $thread->addNote(array( + 'title' => _S('File Import Error'), + 'note' => new TextThreadEntryBody($error), + 'poster' => 'SYSTEM', + 'staffId' => 0, + )); + } continue; } @@ -2478,7 +2487,7 @@ implements TemplateVariable { )); } - function addNote($vars, &$errors) { + function addNote($vars, &$errors=array()) { //Add ticket Id. $vars['threadId'] = $this->getId(); -- GitLab