From 92f936e1bede64e11a02661c60e3ebc562e5920d Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Tue, 20 Jan 2026 17:01:42 -0500 Subject: [PATCH] fix: Fix upload_attachment.php AuditLogModel call - Fix AuditLogModel instantiation with proper $conn parameter - Fix log() call parameter order (details should be array, not ipAddress) Co-Authored-By: Claude Opus 4.5 --- api/upload_attachment.php | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/api/upload_attachment.php b/api/upload_attachment.php index 1520773..f7dcf74 100644 --- a/api/upload_attachment.php +++ b/api/upload_attachment.php @@ -171,20 +171,28 @@ try { } // Log the upload - $auditLog = new AuditLogModel(); - $auditLog->log( - $_SESSION['user']['user_id'], - 'attachment_upload', - 'ticket_attachments', - $attachmentId, - null, - json_encode([ - 'ticket_id' => $ticketId, - 'filename' => $originalFilename, - 'size' => $file['size'], - 'mime_type' => $mimeType - ]) + $conn = new mysqli( + $GLOBALS['config']['DB_HOST'], + $GLOBALS['config']['DB_USER'], + $GLOBALS['config']['DB_PASS'], + $GLOBALS['config']['DB_NAME'] ); + if (!$conn->connect_error) { + $auditLog = new AuditLogModel($conn); + $auditLog->log( + $_SESSION['user']['user_id'], + 'attachment_upload', + 'ticket_attachments', + (string)$attachmentId, + [ + 'ticket_id' => $ticketId, + 'filename' => $originalFilename, + 'size' => $file['size'], + 'mime_type' => $mimeType + ] + ); + $conn->close(); + } ResponseHelper::created([ 'attachment_id' => $attachmentId,