Another error has been found in version 3.6.0.
Action: Adding a note to a ticket
Result: SQL Execution Error
Response with debugging enabled:
The issue is due to an empty IN () condition at the end — it's invalid to use an empty list inside an IN clause. This occurs when the ticket has no collaborator users assigned.Could not execute SQL:
SELECT COUNT(*) FROM hesk_users WHERE (id='14' AND notify_note='1') OR (notify_collaborator_note='1' AND id IN ())
MySQL response:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '))' at line 1.
Proposed Fix (worked for me):
In the file admin_ticket.php, locate this section (around line 508):
Code: Select all
$res = hesk_dbQuery("SELECT COUNT(*) FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` WHERE (`id`='".intval($ticket['owner'])."' AND `notify_note`='1') OR (`notify_collaborator_note`='1' AND `id` IN (".implode(",", $ticket['collaborators'])."))");
Code: Select all
$collaborators_sql = count($ticket['collaborators']) ? "(`notify_collaborator_note`='1' AND `id` IN (".implode(",", $ticket['collaborators'])."))" : "0";
$res = hesk_dbQuery("SELECT COUNT(*) FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` WHERE (`id`='".intval($ticket['owner'])."' AND `notify_note`='1') OR ".$collaborators_sql);
- First check if there are any collaborators.
- If there are, include them in the query using the IN clause.
- If there are no collaborators, replace that part of the condition with "0" (false), which effectively skips it.
You might also want to consider adding additional error checking to ensure that $ticket['collaborators'] is always an array (even if empty), to prevent potential issues elsewhere in the code.