2016-02-27, 06:07 PM
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 ...
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 ...