- Patch #218403 by Gabor, catch, Arancaytar, keith, doug, et al: duplicate entry errors in search idexer due to collation issues.
parent
2fefff5914
commit
a4aac75668
|
@ -575,7 +575,12 @@ function search_index($sid, $type, $text) {
|
||||||
|
|
||||||
// Insert results into search index
|
// Insert results into search index
|
||||||
foreach ($results[0] as $word => $score) {
|
foreach ($results[0] as $word => $score) {
|
||||||
|
// The database will collate similar words (accented and non-accented forms, etc.),
|
||||||
|
// and the score is additive, so first add and then insert.
|
||||||
|
db_query("UPDATE {search_index} SET score = score + %d WHERE word = '%s' AND sid = '%d' AND type = '%s'", $score, $word, $sid, $type);
|
||||||
|
if (!db_affected_rows()) {
|
||||||
db_query("INSERT INTO {search_index} (word, sid, type, score) VALUES ('%s', %d, '%s', %f)", $word, $sid, $type, $score);
|
db_query("INSERT INTO {search_index} (word, sid, type, score) VALUES ('%s', %d, '%s', %f)", $word, $sid, $type, $score);
|
||||||
|
}
|
||||||
search_dirty($word);
|
search_dirty($word);
|
||||||
}
|
}
|
||||||
unset($results[0]);
|
unset($results[0]);
|
||||||
|
|
Loading…
Reference in New Issue