From adb4275c429720a2ef8bde453b6bb0aaece27c69 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Thu, 25 Jul 2013 15:48:47 +0000
Subject: [PATCH] Only set "ft" field if requested

The "ft" field does not exist when the attachment migration takes place.
Therefore, attachment migration will fail because the records cannot be
inserted into the database due to the missing "ft" field.
---
 include/class.file.php | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/include/class.file.php b/include/class.file.php
index d4ea01f33..9e85630c7 100644
--- a/include/class.file.php
+++ b/include/class.file.php
@@ -234,16 +234,18 @@ class AttachmentFile {
             $file['hash']=MD5(MD5($file['data']).time());
         if(!$file['size'])
             $file['size']=strlen($file['data']);
-        if(!$file['filetype'])
-            $file['filetype'] = 'T';
 
         $sql='INSERT INTO '.FILE_TABLE.' SET created=NOW() '
             .',type='.db_input($file['type'])
-            .',ft='.db_input($file['filetype'])
             .',size='.db_input($file['size'])
             .',name='.db_input(Format::file_name($file['name']))
             .',hash='.db_input($file['hash']);
 
+        # XXX: ft does not exists during the upgrade when attachments are
+        #      migrated!
+        if(isset($file['filetype']))
+            $sql.=',ft='.db_input($file['filetype']);
+
         if (!(db_query($sql) && ($id=db_insert_id())))
             return false;
 
-- 
GitLab