Fix ticket ID handling in assign and delete_attachment APIs
assign_ticket.php: preserve string ticket ID (ctype_digit validation) instead of (int) cast for consistent audit logging and URL generation. delete_attachment.php: use string ticket_id from DB for the upload directory path — (int) cast was stripping leading zeros, causing the wrong path (/uploads/123456/) instead of /uploads/000123456/. Also pass raw string to getTicketById() to let TicketModel handle type coercion. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -14,14 +14,15 @@ if (!is_array($data)) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$ticketId = isset($data['ticket_id']) ? (int)$data['ticket_id'] : 0;
|
||||
$ticketIdRaw = isset($data['ticket_id']) ? trim((string)$data['ticket_id']) : '';
|
||||
$assignedTo = $data['assigned_to'] ?? null;
|
||||
|
||||
if ($ticketId <= 0) {
|
||||
if (!ctype_digit($ticketIdRaw) || (int)$ticketIdRaw <= 0) {
|
||||
http_response_code(400);
|
||||
echo json_encode(['success' => false, 'error' => 'Ticket ID required']);
|
||||
exit;
|
||||
}
|
||||
$ticketId = $ticketIdRaw;
|
||||
|
||||
$ticketModel = new TicketModel($conn);
|
||||
$auditLogModel = new AuditLogModel($conn);
|
||||
|
||||
Reference in New Issue
Block a user