diff options
author | Nils Adermann <naderman@naderman.de> | 2006-05-20 16:50:57 +0000 |
---|---|---|
committer | Nils Adermann <naderman@naderman.de> | 2006-05-20 16:50:57 +0000 |
commit | 25d6fbed2a3c4d7212163d91ffb9d207f3c0d006 (patch) | |
tree | befa2d0a7798a8e99b5cb629242de0fe3fa827ad | |
parent | e4ac133954c00c3845ce369518be424d82ecf429 (diff) | |
download | forums-25d6fbed2a3c4d7212163d91ffb9d207f3c0d006.tar forums-25d6fbed2a3c4d7212163d91ffb9d207f3c0d006.tar.gz forums-25d6fbed2a3c4d7212163d91ffb9d207f3c0d006.tar.bz2 forums-25d6fbed2a3c4d7212163d91ffb9d207f3c0d006.tar.xz forums-25d6fbed2a3c4d7212163d91ffb9d207f3c0d006.zip |
- fix a nasty bug in search indexing
git-svn-id: file:///svn/phpbb/trunk@5950 89ea8834-ac86-4346-8a33-228a782c2dd0
-rwxr-xr-x | phpBB/includes/search/fulltext_native.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php index 2c50c5f9fd..2593136f10 100755 --- a/phpBB/includes/search/fulltext_native.php +++ b/phpBB/includes/search/fulltext_native.php @@ -822,6 +822,9 @@ class fulltext_native extends search_backend case 'mssql': case 'mssql_odbc': 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)); $db->sql_query($sql); break; @@ -883,6 +886,22 @@ class fulltext_native extends search_backend } /** + * 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 */ function index_remove($post_ids, $author_ids) |