From 3dfbfdb8ef849dadc794b66ffbf24d94377babbc Mon Sep 17 00:00:00 2001 From: Andrew Short Date: Tue, 8 Oct 2013 18:56:07 +1100 Subject: [PATCH] BUG: Ensure excerpts are returned as HTMLText instances. a7629c8bb260fd6d23c04dee7520222ca0c070c5 inadvertently made it so they were returned as plain strings due to the replace operation. --- code/solr/SolrIndex.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/code/solr/SolrIndex.php b/code/solr/SolrIndex.php index 14da30d..66479f4 100644 --- a/code/solr/SolrIndex.php +++ b/code/solr/SolrIndex.php @@ -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) + ) + ); } } }