mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/17387] Return entire post text for zero or negative length value
In according to 'Default number of returned characters' setting ACP explanation `A value of 0 will return the entire post`. Do the same for negative values too PHPBB-17387
This commit is contained in:
parent
a7b673a1b6
commit
8acba2db02
2 changed files with 4 additions and 4 deletions
|
@ -329,10 +329,10 @@ function get_context(string $text, array $words, int $length = 400): string
|
||||||
{
|
{
|
||||||
if ($length <= 0)
|
if ($length <= 0)
|
||||||
{
|
{
|
||||||
return '...';
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we need to turn the entities back into their original form, to not cut the message in between them
|
// We need to turn the entities back into their original form, to not cut the message in between them
|
||||||
$text = html_entity_decode($text);
|
$text = html_entity_decode($text);
|
||||||
|
|
||||||
// Replace all spaces/invisible characters with single spaces
|
// Replace all spaces/invisible characters with single spaces
|
||||||
|
|
|
@ -81,13 +81,13 @@ class phpbb_functions_content_get_context_test extends TestCase
|
||||||
'text' => 'This is a sample text.',
|
'text' => 'This is a sample text.',
|
||||||
'words' => ['sample'],
|
'words' => ['sample'],
|
||||||
'length' => 0,
|
'length' => 0,
|
||||||
'expected' => '...',
|
'expected' => 'This is a sample text.',
|
||||||
],
|
],
|
||||||
'negative length' => [
|
'negative length' => [
|
||||||
'text' => 'This is a sample text.',
|
'text' => 'This is a sample text.',
|
||||||
'words' => ['sample'],
|
'words' => ['sample'],
|
||||||
'length' => -10,
|
'length' => -10,
|
||||||
'expected' => '...',
|
'expected' => 'This is a sample text.',
|
||||||
],
|
],
|
||||||
'ellipses_beginning' => [
|
'ellipses_beginning' => [
|
||||||
'text' => 'foo foo foo foo foo foo foo foo bar',
|
'text' => 'foo foo foo foo foo foo foo foo bar',
|
||||||
|
|
Loading…
Add table
Reference in a new issue