Biology Forums - Study Force

Discussion Suggestions and Updates Topic started by: Spiros on Feb 22, 2022



Title: Each word in your search query must be at least two characters long.
Post by: Spiros on Feb 22, 2022
I wonder how did you manage to solve this bug in the forum? (I have an SMF forum myself.)


Title: Re: Each word in your search query must be at least two characters long.
Post by: bio_man on Feb 22, 2022
Hi Spiros (https://biology-forums.com/index.php?action=profile;u=1113259)

The logic we used was if the string length is less than 2 characters long, we set its value to empty. Thus, when the search is conducted, the word isn't included in the search query.

Does that make sense?


Title: Re: Each word in your search query must be at least two characters long.
Post by: Spiros on Feb 23, 2022
Thanks, bio_man!

Do you have the code edits available? Not a programmer so I could not figure it out myself -:)


Title: Re: Each word in your search query must be at least two characters long.
Post by: bio_man on Feb 23, 2022
In
Code:
Search.php

Locate
Code:
elseif ($smcFunc['strlen']($value) < 2)

Within the {, remove the code inside and replace it with:

Code:
$value = '';
unset($searchArray[$index]);

See if that helps


Title: Re: Each word in your search query must be at least two characters long.
Post by: Spiros on Feb 23, 2022
Wow, such a simple thing and they have not changed it in default SMF! Thanks a million!


Title: Re: Each word in your search query must be at least two characters long.
Post by: bio_man on Feb 23, 2022
No problem. It is taxing on the server to search all instances of words that are two characters long. So I think there's a reason for that madness 😄


Title: Re: Each word in your search query must be at least two characters long.
Post by: Spiros on Feb 23, 2022
You mean all instances of words that are less than two characters long? But they could simply be skipped/removed from the query before it is passed to the search function.

I see here I get:

Quote
"Search tip: Word's that are one character in length are automatically omitted, unless the "phrase is quoted".

Do you use the same code change?


Title: Re: Each word in your search query must be at least two characters long.
Post by: bio_man on Feb 23, 2022
Actually, the code you implemented simply disables the error. You could even remove the $value = ''; and it'll still work.