diff --git a/models/TicketModel.php b/models/TicketModel.php index 87bad9c..c73c8ce 100644 --- a/models/TicketModel.php +++ b/models/TicketModel.php @@ -81,9 +81,12 @@ class TicketModel { if ($search && !empty($search)) { if ($this->hasFulltextIndex()) { // MATCH...AGAINST for indexed full-text search (much faster at scale) + // Strip MySQL boolean mode special chars to prevent parse errors on user input + $ftSearch = preg_replace('/[+\-><()\~*"@]+/', ' ', $search); + $ftSearch = trim(preg_replace('/\s+/', ' ', $ftSearch)) . '*'; $whereConditions[] = "(MATCH(t.title, t.description) AGAINST (? IN BOOLEAN MODE) OR t.ticket_id LIKE ? OR t.category LIKE ? OR t.type LIKE ?)"; $searchTerm = "%$search%"; - $params = array_merge($params, [$search . '*', $searchTerm, $searchTerm, $searchTerm]); + $params = array_merge($params, [$ftSearch, $searchTerm, $searchTerm, $searchTerm]); $paramTypes .= 'ssss'; } else { $whereConditions[] = "(t.title LIKE ? OR t.description LIKE ? OR t.ticket_id LIKE ? OR t.category LIKE ? OR t.type LIKE ?)";