Added a better handling of simultaneous updates of the search index.

master
Loic d'Anterroches 2010-02-14 22:01:46 +01:00
parent 355f9ca05f
commit 96e8f4ae3c
1 changed files with 15 additions and 3 deletions

View File

@ -127,9 +127,21 @@ class IDF_Search extends Pluf_Search
if ($ids[$i] === null) {
$word = new Pluf_Search_Word();
$word->word = $words_flat[$i];
$word->create();
$ids[$i] = $word->id;
$new_words++;
try {
$word->create();
$new_words++;
$ids[$i] = $word->id;
} catch (Exception $e) {
// 100% of the time, the word has been created
// by another process in the background.
$r_ids = self::getWordIds(array($word->word));
if ($r_ids[0]) {
$ids[$i] = $r_ids[0];
} else {
// give up for this word
continue;
}
}
}
if (isset($done[$ids[$i]])) {
continue;