This warning only appear on a very specific edge case. Here are the step to reproduces:

  1. Create 2 view panes which will make a full text search on two different content types.
  2. On the 2 views, set the pagination to show only 1 item by page.
  3. On the 2 views add an "excerpt" field.
  4. In search api, enable the "Highlighting" processor.
  5. Create two items of the first content type, and only one item of the second content type (all with 'lorem' in title to be able to seach the 3 items at once)
  6. Add the 2 views to a search panel
  7. Now if you search 'lorem' it displays the 2 view panes with 2 pagination, if you go to the second page one of the view is hidden as expected but there is a warning.

Here is the warning:

Warning : Invalid argument supplied for foreach() dans SearchApiHighlight->postprocessSearchResults() (ligne 145 dans /.../sites/all/modules/search_api/includes/processor_highlight.inc).

Now, the error is difficult to reproduce but the issue itself is easy to fix. Patch following.

Comments

idflood’s picture

Status: Active » Needs review
StatusFileSize
new601 bytes

The error happens on this line:

foreach ($response['results'] as $id => &$result) {

So the fix is simply to check the presence of the 'results' key before doing the function.

drunken monkey’s picture

Title: Invalid argument in SearchApiHighlight->postprocessSearchResults » Fix Highlighting processor for queries without returned results
Component: Framework » Plugins
Status: Needs review » Fixed

I think this might also be reproducible when you just set the view/search to display no items?
Anyways, thanks for reporting this and providing a patch! I modified it a bit and committed it right away (seems innocent enough).

  • Commit 30d12b9 on 7.x-1.x authored by idflood, committed by drunken monkey:
    Issue #2272983 by idflood, drunken monkey: Fixed Highlighting processor...

Status: Fixed » Closed (fixed)

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