[ticket/15403] Return first fragment of text if there is no coincidences

PHPBB-15403
This commit is contained in:
Ruben Calvo 2024-07-09 17:09:06 +02:00
parent a2e7205154
commit 7763969625
No known key found for this signature in database

View file

@ -399,10 +399,10 @@ function get_context($text, $words, $length = 400)
// Get the last fragment // Get the last fragment
$fragments[] = $fragment; $fragments[] = $fragment;
$output = htmlentities(implode('', $fragments)); return htmlentities(implode('', $fragments));
} }
return $output; return htmlentities($text_length >= $length + 3 ? utf8_substr($text, 0, $length) . ' ...' : $text);
} }
/** /**