mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Fix "mb_stripos(): Empty delimiter" warning when no search-keywords are given for DBText::ContextSummary
.
Add unit-test to cover that case.
This commit is contained in:
parent
68f5d8b37e
commit
40c2e299a0
@ -198,7 +198,7 @@ class DBText extends DBString
|
|||||||
$keywords = Convert::raw2xml($keywords);
|
$keywords = Convert::raw2xml($keywords);
|
||||||
|
|
||||||
// Find the search string
|
// 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
|
// We want to search string to be in the middle of our block to give it some context
|
||||||
$position = max(0, $position - ($characters / 2));
|
$position = max(0, $position - ($characters / 2));
|
||||||
|
@ -263,6 +263,13 @@ class DBTextTest extends SapphireTest
|
|||||||
'schön',
|
'schön',
|
||||||
// check UTF8 support
|
// check UTF8 support
|
||||||
'both <mark>schön</mark> and können...',
|
'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...',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user