Merge pull request #7905 from bummzack/pulls/fix-empty-delimiter

Fix regression in ContextSummary
This commit is contained in:
Daniel Hensby 2018-03-01 13:02:30 +00:00 committed by GitHub
commit 3cd8c2a985
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -198,7 +198,7 @@ class DBText extends DBString
$keywords = Convert::raw2xml($keywords);
// Find the search string
$position = (int) mb_stripos($text, $keywords);
$position = empty($keywords) ? 0 : (int) mb_stripos($text, $keywords);
// We want to search string to be in the middle of our block to give it some context
$position = max(0, $position - ($characters / 2));

View File

@ -263,6 +263,13 @@ class DBTextTest extends SapphireTest
'schön',
// check UTF8 support
'both <mark>schön</mark> and können...',
],
[
'both schön and können have umlauts',
21,
'',
// check non existant search term
'both schön and können...',
]