BUG: Ensure excerpts are returned as HTMLText instances.

a7629c8bb2 inadvertently made it so
they were returned as plain strings due to the replace operation.
This commit is contained in:
Andrew Short 2013-10-08 18:56:07 +11:00
parent 915219b6c4
commit 3dfbfdb8ef
1 changed files with 11 additions and 4 deletions

View File

@ -439,10 +439,17 @@ abstract class SolrIndex extends SearchIndex {
foreach($res->highlighting->$docId as $field => $highlights) {
$combinedHighlights = array_merge($combinedHighlights, $highlights);
}
$result->Excerpt = DBField::create_field('HTMLText', implode(' ... ', $combinedHighlights));
// Remove entity-encoded U+FFFD REPLACEMENT CHARACTER.
// It signifies non-displayable characters, and shows up as such itself in browsers (questionmark icon)
$result->Excerpt = str_replace('�', '', $result->Excerpt);
// Remove entity-encoded U+FFFD replacement character. It signifies non-displayable characters,
// and shows up as an encoding error in browsers.
$result->Excerpt = DBField::create_field(
'HTMLText',
str_replace(
'�',
'',
implode(' ... ', $combinedHighlights)
)
);
}
}
}