PDA

View Full Version : Search Hangs


dsstowe
03-16-2004, 02:27 AM
If you search for a 0 "zero" followed by a space and then anything else. the search hangs and puts a heavy load on server.

Charter
03-16-2004, 02:40 AM
Hi. Thanks for the post. Moved to bugs. To fix do the following.

In search_function.php find:

if (SMALL_WORDS_SIZE >= 1) {
while (ereg(' ([^ ]{1,'.SMALL_WORDS_SIZE.'}) | ([^ ]{1,'.SMALL_WORDS_SIZE.'})$|^([^ ]{1,'.SMALL_WORDS_SIZE.'}) ',$test_short,$regs)) {
for ($n=1; $n <=3; $n++) {
if ($regs[$n]) {
$ignore .= "\"".stripslashes($regs[$n])."\", ";
$test_short = trim(str_replace($regs[$n],"",$test_short));
}
}
}
}

and replace with the following:

if (SMALL_WORDS_SIZE >= 1) {
while (ereg('( [^ ]{1,'.SMALL_WORDS_SIZE.'} )|( [^ ]{1,'.SMALL_WORDS_SIZE.'})$|^([^ ]{1,'.SMALL_WORDS_SIZE.'} )',$test_short,$regs)) {
for ($n=1; $n <=3; $n++) {
if (($regs[$n]) || ($reg[$n] == 0)) {
$ignore .= "\"".trim(stripslashes($regs[$n]))."\", ";
$test_short = trim(str_replace($regs[$n],"",$test_short));
}
}
}
if (strlen($test_short) <= SMALL_WORDS_SIZE) {
if (!eregi("\"".$test_short."\", ",$ignore)) {
$ignore .= "\"".stripslashes($test_short)."\", ";
}
$test_short = trim(str_replace($test_short,"",$test_short));
}
}
$ignore = str_replace("\"\", ","",$ignore);

This should prevent the loop as well as correct the display message for too short keywords.

Remember to remove any "word" wrapping in the above code.

tomas
03-16-2004, 10:33 AM
hello list,

maybe - to prevent other yet unknown loops/bugs -
in first line of search.php:


set_time_limit(20);


should help to keep the server live.