mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
- fix a nasty bug in search indexing
git-svn-id: file:///svn/phpbb/trunk@5950 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
e4ac133954
commit
25d6fbed2a
1 changed files with 19 additions and 0 deletions
|
@ -822,6 +822,9 @@ class fulltext_native extends search_backend
|
||||||
case 'mssql':
|
case 'mssql':
|
||||||
case 'mssql_odbc':
|
case 'mssql_odbc':
|
||||||
case 'sqlite':
|
case 'sqlite':
|
||||||
|
// make sure the longest word comes first, so nothing will be truncated
|
||||||
|
usort($new_words, array(&$this, 'strlencmp'));
|
||||||
|
|
||||||
$sql = 'INSERT INTO ' . SEARCH_WORD_TABLE . ' (word_text) ' . implode(' UNION ALL ', preg_replace('#^(.*)$#', "SELECT '\$1'", $new_words));
|
$sql = 'INSERT INTO ' . SEARCH_WORD_TABLE . ' (word_text) ' . implode(' UNION ALL ', preg_replace('#^(.*)$#', "SELECT '\$1'", $new_words));
|
||||||
$db->sql_query($sql);
|
$db->sql_query($sql);
|
||||||
break;
|
break;
|
||||||
|
@ -882,6 +885,22 @@ class fulltext_native extends search_backend
|
||||||
unset($cur_words);
|
unset($cur_words);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used by index() to sort strings by string length, longest first
|
||||||
|
*/
|
||||||
|
function strlencmp($a, $b)
|
||||||
|
{
|
||||||
|
$len_a = strlen($a);
|
||||||
|
$len_b = strlen($b);
|
||||||
|
|
||||||
|
if ($len_a == $len_b)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ($len_a > $len_b) ? -1 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes entries from the wordmatch table for the specified post_ids
|
* Removes entries from the wordmatch table for the specified post_ids
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue