Cannot execute SQL
Cause of the Problem
After some debugging, I found the issue in the SQL INSERT statement in admin_ticket.php, at line 736:
Code: Select all
$q = "INSERT INTO ".hesk_dbEscape($hesk_settings['db_pfix'])."linked_tickets (ticket_id1, ticket_id2, dt_created) VALUES ('".hesk_dbEscape($ticket['id'])."', '".hesk_dbEscape($get_ticket_data['id'])."','".hesk_date()."')";
This mismatch caused MySQL to reject the INSERT operation and triggered the error.
Note: In setups where hesk_date() (or the locale) returns dates in American format (Y-m-d H:i:s), this error may not happen, which is why it can go unnoticed in some environments.
Solution
To resolve this, I modified line 736 to use MySQL’s built-in NOW() function for the dt_created column, which always produces a compatible format:
Code: Select all
$q = "INSERT INTO ".hesk_dbEscape($hesk_settings['db_pfix'])."linked_tickets (ticket_id1, ticket_id2, dt_created) VALUES ('".hesk_dbEscape($ticket['id'])."', '".hesk_dbEscape($get_ticket_data['id'])."', NOW())";
Summary
- File: admin_ticket.php
- Line: 736
- Problem: Incorrect datetime format for dt_created when linking tickets (Brazilian format: d/m/Y H:i:s)
- Note: This issue may not occur in environments using the American date format (Y-m-d H:i:s)
- Solution: Use NOW() in the SQL statement instead of a PHP-formatted date