FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Bug Reports » Bug in search.php (PHP problem, solution inside)
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Bug in search.php (PHP problem, solution inside) [message #22202] Thu, 20 January 2005 09:41 Go to next message
devnull is currently offline  devnull   Germany
Messages: 16
Registered: September 2004
Karma: 0
Junior Member
Some people noticed SQL errors when searching for a number-only string. I traced the bug back to the function "text_to_worda" in search.php; it returns an empty array when $text contains only numbers, effectively leading to a SQL error in line 445, because $qr is empty.

The reason for that is the PHP function str_word_count in line 339. It handles numbers just like whitespace.
http://www.php.net/manual/en/function.str-word-count.php

To fix this, I replaced str_word_count with preg_replace. So far, the search works fine. However, a search containing a number won't return any matches (I guess they are not indexed). But at least the error message is gone.

Original line 339:
$t1 = array_unique(str_word_count(strip_tags(strtolower($text)), 1));
Replaced with:
$t1 = array_unique(preg_split("/\s+/", strip_tags(strtolower($text))));

I'm using FudForum 2.6.6 on Apache/2.0.46 with PHP 4.3.2 (Zend 1.3.0) using MySQL 11.18 Distrib 3.23.58.
Re: Bug in search.php (PHP problem, solution inside) [message #22208 is a reply to message #22202] Thu, 20 January 2005 15:08 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
This was already addressed in later releases.

FUDforum Core Developer
Re: Bug in search.php (PHP problem, solution inside) [message #22210 is a reply to message #22202] Thu, 20 January 2005 15:12 Go to previous messageGo to next message
devnull is currently offline  devnull   Germany
Messages: 16
Registered: September 2004
Karma: 0
Junior Member
Ahh, ok.

I made a bunch of changes to FudForum, so upgrading will be fun... Confused

Re: Bug in search.php (PHP problem, solution inside) [message #22431 is a reply to message #22210] Thu, 03 February 2005 12:52 Go to previous messageGo to next message
papaf is currently offline  papaf   Italy
Messages: 1
Registered: February 2005
Karma: 0
Junior Member
Hi all,
I read that the problem of the mysql error should be fixed by now. But I don't understand if also the search problem is supposed to be fixed: I use 2.6.10rc2 and still cannot search with numbers in the search string.
Is any solution available?

Thanks!
Re: Bug in search.php (PHP problem, solution inside) [message #22438 is a reply to message #22431] Thu, 03 February 2005 14:54 Go to previous message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
The numbers are not being indexed, just as they are not by most indexing systems.

FUDforum Core Developer
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: E-mail confirmation problem
Next Topic: BROKEN lock/unlock files in 2.6.6
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 22:24:47 GMT 2024

Total time taken to generate the page: 0.02259 seconds