diff --git a/include/class.search.php b/include/class.search.php index 47254dd407bf8cd28430bfe25fb6b04f10aa5514..d4616307aa308e42339d6a9473441cc823332574 100644 --- a/include/class.search.php +++ b/include/class.search.php @@ -606,6 +606,8 @@ class MysqlSearchBackend extends SearchBackend { // FILES ------------------------------------ // Flush non-full batch of records + $this->__index(null, true); + if (!$this->_reindexed) { // Stop rebuilding the index $this->getConfig()->set('reindex', 0); diff --git a/include/class.thread.php b/include/class.thread.php index c44cc3659aa0033cc89f4c5096e423469f38e97c..46c0182822e9e7f6beb8d94f91dabca4c3397927 100644 --- a/include/class.thread.php +++ b/include/class.thread.php @@ -1178,6 +1178,9 @@ class ThreadEntry { .' WHERE `id`='.db_input($entry->getId()); if (!db_query($sql) || !db_affected_rows()) return false; + + // Set the $entry here for search indexing + $entry->ht['body'] = $body; } // Email message id @@ -1532,9 +1535,14 @@ class HtmlThreadBody extends ThreadBody { } function getSearchable() { - // <br> -> \n - $body = preg_replace(array('`<br(\s*)?/?>`i', '`</div>`i'), "\n", $this->body); - $body = Format::htmldecode(Format::striptags($body)); + // Replace tag chars with spaces (to ensure words are separated) + $body = Format::html($this->body, array('hook_tag' => function($el, $attributes=0) { + static $non_ws = array('wbr' => 1); + return (isset($non_ws[$el])) ? '' : ' '; + })); + // Collapse multiple white-spaces + $body = html_entity_decode($body, ENT_QUOTES); + $body = preg_replace('`\s+`u', ' ', $body); return Format::searchable($body); }