Search action is not working
fedesanchez opened this issue · 2 comments
fedesanchez commented
Issue Summary
Hello,
When there's a query of > 3 chars an error is displayed:
"Statement could not be executed (42000 - 1064 - You have an error in your SQL syntax"
Steps to Reproduce
- clone and install
- add theme
- Do a search or go to http://localhost:port/search/something
Additional info
- Leafpub version: current dev, after 1.1.0-beta4
- PHP version: 7
- Affected browsers: all
- Operating system: linux
fedesanchez commented
This issue is due to two missing columns in view_posts
--Models/Post.php
$is_fulltext = mb_strlen($options['query']) > 3;
if($is_fulltext) {
$columns[] = ['title_score' , new \Zend\Db\Sql\Expression('MATCH(slug, title) AGAINST (' . $options['query'] . ')')];
$columns[] = ['content_score' , new \Zend\Db\Sql\Expression('MATCH(content) AGAINST (' . $options['query'] . ')')];
}
and later ...
// Generate order SQL
if($is_fulltext) {
$select->order('(title_score * 1.5 + content_score)');
} else {
$select->order('sticky '. $options['sort'])->order('pub_date '. $options['sort'])->order('id '. $options['sort']);
}
So the question is, do I change these lines or the model has to be updated?
karsasmus commented
Hi @fedesanchez ,
this issue was fixed with the latest commit.
Thanks for creating the issue 🙂