Skip to content

Commit

Permalink
Merge branch '1.7' into 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
andrerom committed Oct 4, 2019
2 parents 13359a2 + 48b252a commit 98c1154
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/FieldType/XmlText/SearchField.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ private function extractText(DOMNode $node)
private function extractShortText(DOMDocument $document)
{
$result = null;
// try to extract first paragraph/tag
if ($section = $document->documentElement->firstChild) {
$textDom = $section->firstChild;

Expand All @@ -95,7 +96,10 @@ private function extractShortText(DOMDocument $document)
$result = $document->documentElement->textContent;
}

return trim($result);
// In case of newlines, extract first line. Also limit size to 255 which is maxsize on sql impl.
$lines = preg_split('/\r\n|\n|\r/', trim($result), -1, PREG_SPLIT_NO_EMPTY);

return empty($lines) ? '' : trim(mb_substr($lines[0], 0, 255));
}

/**
Expand Down

0 comments on commit 98c1154

Please sign in to comment.