From d1a9161f2483057d4ab783a9d8dc4ea774ffa33f Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Mon, 18 Apr 2016 20:23:18 -0500
Subject: [PATCH] oops: Fix max of a single attachment

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

diff --git a/include/class.thread.php b/include/class.thread.php
index f6a2a1730..31b2c5c3d 100644
--- a/include/class.thread.php
+++ b/include/class.thread.php
@@ -933,6 +933,10 @@ implements TemplateVariable {
             if (is_array($file))
                 $F += $file;
 
+            // Key is required for CID rewriting in the body
+            if (!isset($F['key']) && ($AF = AttachmentFile::lookup($F['id'])))
+                $F['key'] = $AF->key;
+
             $ids[] = $F;
         }
         return $ids;
@@ -1382,7 +1386,8 @@ implements TemplateVariable {
                         $files[$i]['inline'] = true;
                 }
                 foreach ($entry->normalizeFileInfo($files) as $F) {
-                    // Deduplicate on the `key` attribute
+                    // Deduplicate on the `key` attribute. The key is
+                    // necessary for the CID rewrite below
                     $attached_files[$F['key']] = $F;
                 }
             }
-- 
GitLab