Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search crashes: Invalid method PHPCuong\Faq\Block\Search\Search::filterProvider #22

Open
dazz397 opened this issue Dec 15, 2017 · 4 comments

Comments

@dazz397
Copy link

dazz397 commented Dec 15, 2017

If you search for something that matches a value the search will crash
/faq/search/?s=feet

If you search for something with no matches it returns fine
/faq/search/?s=xxxxx

I was able to replicate this on 2.1.7 and 2.1.7.1

@SherifElfadaly
Copy link

I have created a pull request to fix this issue. Check #23

@ghost
Copy link

ghost commented Jan 4, 2018

@SherifElfadaly great patch! I can confirm the patch is working and to me it should be merged to master as soon as possibile since at the current state the search functionality is broken.

@lamaithanh
Copy link

@SherifElfadaly fixed a part of the search results. I searched with more than 3 words which were copied from one of the answers. But results listed all questions in my English Store (some times it also included all questions from my other Chinese Store)

@dazz397
Copy link
Author

dazz397 commented Aug 30, 2022

@lamaithanh I know this is years later but the query is not built correctly when there are multiple keywords. You can correct this by adding parenthesis to the query at line 175 like this:

    for ($i=0; $i<count($explode); $i++) {
        if ($i == 0) {
            $select->where('(faq.title LIKE ?', "%{$explode[$i]}%");
        } else {
            $select->orWhere('faq.title LIKE ?', "%{$explode[$i]}%");
        }
        if ($i == count($explode)-1) {
            $select->orWhere('faq.content LIKE ?)', "%{$explode[$i]}%");
        } else {
            $select->orWhere('faq.content LIKE ?', "%{$explode[$i]}%");
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants