Getting a Notice: Undefined index: highlight_partial in SearchApiHighlight->createExcerpt() (rule 363 of /var/www/html/web/sites/all/modules/contrib/search_api/includes/processor_highlight.inc).

This occurs after searching and after narrowing down of the search results.
Seen with the 1.26 version but not with the 1.25 version.

Comments

Johan den Hollander created an issue. See original summary.

johan den hollander’s picture

Issue summary: View changes
johan den hollander’s picture

Status: Active » Needs work
ecvandenberg’s picture

Same here on a website on PHP 7.1.26
And on another site on PHP 5.6.40
Config:
drupal 7.65
Search API 7.x-1.26
Search API Database Search 7.x-1.7

The excerpt function seems to work fine though...

rclemings’s picture

PHP 7.1.27
Drupal 7.65
Search API 7.x-1.26

Line 363 in v1.26:
if (!$this->options['highlight_partial']) {

Line 363 in v1.25:
if (empty($this->options['highlight_partial'])) {

Changing it back to what it was in v1.25 eliminates the error for me, but I'm reluctant to do a patch without understanding why the change was made in the first place.

This looks like the commit/issue where it happened:
https://cgit.drupalcode.org/search_api/commit/?id=27b6cbb
https://www.drupal.org/node/2990940

rclemings’s picture

This seems to work as well and may be more in line with what the v1.26 change intended:

if (!isset($this->options['highlight_partial'])) {

drunken monkey’s picture

Component: General code » Plugins
Status: Needs work » Needs review
Issue tags: -undefined index highlight_partial
StatusFileSize
new683 bytes

Thanks a lot for reporting this! The problem seems to stem from backporting a patch from D8 – while plugin options there are centrally defined and therefore always have a default value, we do have to use empty() in D7, of course.
Patch attached, please test/review!

PS: It seems you (like many others – it's really easy to misinterpret) are confused by the "Issue tags" field. As the guidelines state, they aren't meant for free text tags related to the issue, but only for specific categorization purposes, usually by module maintainers.
So, if you aren't sure your current usage is correct, please just leave the field empty.

PPS: “Needs work“ status only applies if there is already a patch. Otherwise, “Active“ is the correct status.

rclemings’s picture

Status: Needs review » Reviewed & tested by the community

Patch works perfectly, thanks.

I'm not sure to whom your other comments were directed but I think the issue tags and for certain the "needs work" came from the OP, not me.

johan den hollander’s picture

Yeah, patch works. I suppose the other comments were directed to me. Thank you for explaining that to me @drunken Monkey.

kreatil’s picture

The Patch fixes the error for me.

  • drunken monkey committed 2c357e0 on 7.x-1.x
    Issue #3040980 by drunken monkey: Fixed undefined index notice in...
drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Good to hear, thanks a lot for reporting back, everyone!
Committed.

rclemings: Yes, the P(P)S was of course directed at Johan, not you.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

thetaPC’s picture

I noticed that the commit was pushed to the dev branch. Please, push it to the next update (7.x-1.2x) since the Panopoly profile is currently using Search API 7.x-1.26. This causes the error to still appear.

The patch works great on 7.x-1.26. Thank you.