mirror of
https://github.com/flarum/framework.git
synced 2025-02-21 09:53:27 +08:00
Prevent @ character used in searches from crashing MySQL 🙄
This commit is contained in:
parent
bc092c48d4
commit
d13229a1fd
@ -29,6 +29,10 @@ class FulltextGambit implements GambitInterface
|
||||
throw new LogicException('This gambit can only be applied on a DiscussionSearch');
|
||||
}
|
||||
|
||||
// The @ character crashes fulltext searches on InnoDB tables.
|
||||
// See https://bugs.mysql.com/bug.php?id=74042
|
||||
$bit = str_replace('@', '*', $bit);
|
||||
|
||||
$search->getQuery()
|
||||
->selectRaw('SUBSTRING_INDEX(GROUP_CONCAT(posts.id ORDER BY MATCH(posts.content) AGAINST (?) DESC), \',\', 1) as most_relevant_post_id', [$bit])
|
||||
->leftJoin('posts', 'posts.discussion_id', '=', 'discussions.id')
|
||||
|
Loading…
x
Reference in New Issue
Block a user