$text = '12345678901234567890 12345678901234567890123456789012345678901234567890123456789012345_test_1234567890123456789012345678901234567890 ';
$keys = 'test';
print search_excerpt($keys, $text);
this example returns '... ...' snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | search_excerpt_on_long_strings_d7-2018777-1.patch | 537 bytes | vectoroc |
| #1 | 2018777-d7.patch | 537 bytes | vectoroc |
| #1 | 2018777-d6.patch | 576 bytes | vectoroc |
Comments
Comment #1
vectoroc commentedComment #3
vectoroc commentedComment #4
vectoroc commentedComment #5
jhodgdonThis is most likely also an issue in Drupal 8.x. Assuming that is the case:
- We need to port the patch there and fix it there first, then deal with Drupal 7
- We should probably postpone the issue until #916086: search_excerpt() doesn't highlight words that are matched via search_simplify() goes in, which might fix the issue anyway.
- It needs a test. Preferably with an actual node failing in displaying search results.
Comment #6
jhodgdonThe issue this was postponed on has been fixed in D8.
So we need to test and see if this bug still exists in D8. If not, we can just mark this as a duplicate of that other issue, because once that one is ported to d7 this issue will also vanish there. If it is still an issue in 8, we need a test and a new patch.
Comment #7
jhodgdonIf you do:
in the current Drupal 8, you will get $text back as the output, with "test" highlighted both when it's a bare word and when it's in the middle of the long string of numbers. So this is now working in Drupal 8.
I'm assuming it will also be fixed in D7 when #916086: search_excerpt() doesn't highlight words that are matched via search_simplify() is ported there. So I'm going to go ahead and close this as a duplicate of that issue.