$text = '12345678901234567890 12345678901234567890123456789012345678901234567890123456789012345_test_1234567890123456789012345678901234567890 ';
$keys = 'test';
print search_excerpt($keys, $text);

this example returns '... ...' snippet

Comments

vectoroc’s picture

Status: Active » Needs review
StatusFileSize
new576 bytes
new537 bytes

Status: Needs review » Needs work

The last submitted patch, 2018777-d6.patch, failed testing.

vectoroc’s picture

vectoroc’s picture

Status: Needs work » Needs review
jhodgdon’s picture

Version: 7.x-dev » 8.x-dev
Issue summary: View changes
Status: Needs review » Postponed
Issue tags: +Needs tests
Related issues: +#916086: search_excerpt() doesn't highlight words that are matched via search_simplify()

This 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.

jhodgdon’s picture

Status: Postponed » Needs work

The 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.

jhodgdon’s picture

Status: Needs work » Closed (duplicate)

If you do:

$text = '12345678901234567890 test 12345678901234567890123456789012345678901234567890123456789012345_test_1234567890123456789012345678901234567890 ';
$keys = 'test';
print search_excerpt($keys, $text);

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.