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
Searching for "orange" will find "angel" in non-fulltext search #2349
Comments
I guess something like: $stop = false;
while($stop == false)
{
if(substr($keywords, 0, 3) == 'or ')
{
$keywords = substr($keywords, 3);
}
elseif(substr($keywords, 0, 4) == 'and ')
{
$keywords = substr($keywords, 4);
}
else
{
$stop = true;
}
} would work, but then I'm not entirely sure what's the purpose of it (what exactly does it prevent?). |
$keywords = preg_replace('#^(and|or)(\s|$)((and|or)\s)*#', '', $keywords); |
Ah yes, forgot about single keyword. Are those MyBB-specific keywords? What's their function or rather usage (it could be documented somewhere)? $keywords = preg_replace('/^((and|or)(\s|$))+/', '', $keywords); |
While a regular user doesn't need to know, searching for btw: These keywords and search expressions are quite common. Fulltext search supports some more things, too. |
Noone needs to know, but then what's the point of having an unused feature? I think it wouldn't hurt to add some tips under the keyword textbox: http://community.mybb.com/search.php depending on the search type. I'd do that in the PR I'm just preparing but then I'm not sure of all tricks myself. Could you list them? |
It depends whether fulltext search is used or not. |
Doesn't regular search also support |
You are right. I've missed that. |
As the title says. Also added advcanced mechanics descriptions in search.php. mybb#2349
@Destroy666x You seem to have made a commit which seems to fix this but never created a PR with it? Is there anything missing? |
@Destroy666x @effone @Shade- and others devs - there is a FIX from Destroy in his repo, can you check if it is fine? I am trying to test it on my board, seems fine but needs proper testing. I can recreate the PR if it will be fine. Let me know, thank you! |
This one is OK #2349 (comment) and really more simple. I think its the best fix. |
Hmm, maybe some discussion? |
If users can't use these words (and, or) we could add some warning while typing (there is no such feature altogether as of now). Regardless of ultimate fix regarding the front-end some in-line form verification should be added at some point and consider this specific case if so. |
It's not THIS word, it's allw aord styarting by or and and … orange for example Fixed by a simple edit #4707 |
I can not reproduce with the fix and search "Cahiers d'Ulysse" return Cahiers d'Ulysse topics. |
Non-Fulltext-Search in MyBB ignores "and" and "or" of the first entered keyword of the search.
If I search for "orange", MyBB will actually search for "ange". I can't search for "andi", because Mybb will complain that my search keyword is only one character long.
The reason is a bug in clean_keywords function:
https://github.com/mybb/mybb/blob/featur...h.php#L243
https://github.com/mybb/mybb/blob/featur...h.php#L248
At these lines, "and" and "or" will be removed from the search string, if they are at the beginning of the first keyword.
I suggest removing the two "if"-statements completely, as they are broken in many ways. Not only will they currently unintentionally remove the first characters of a matching keyword, they also don't protect against "and" and "or" keywords at the first position of a search query (the intention of these lines) if fixed to not cut off longer keywords:
"or test" would become "test" (correct)
"and test" would become "test" (correct)
"or or test" would become "or test" (wrong)
"and and test" would become "and test" (wrong)
"or and test" would become "test" (correct)
"and or test" woud become "or test" (wrong)
and so on ...
Original thread: Searching for "orange" will find "angel" in non-fulltext search
The text was updated successfully, but these errors were encountered: