Problem/Motivation

Certain values in a Views "Search: Search term" filter can cause the below PHP warning:

Warning: Invalid argument supplied for foreach() in views_join->build_join() (line 1548 of ./sites/all/modules/views/includes/handlers.inc).

I believe this happens because the following declaration in modules/search.view.inc uses string "extra" data instead of arrays:

  $data['search_dataset']['table']['join'] = array(
    'node' => array(
      'left_table' => 'search_index',
      'left_field' => 'sid',
      'field' => 'sid',
      'extra' => 'search_index.type = search_dataset.type',
      'type' => 'INNER',
    ),
    'users' => array(
      'left_table' => 'search_index',
      'left_field' => 'sid',
      'field' => 'sid',
      'extra' => 'search_index.type = search_dataset.type',
      'type' => 'INNER',
    ),
  );

I am not sure exactly how the warning is triggered outside of the fact that I can reproduce it consistently only when the search terms include a string below the search string length threshold (default 3). E.g. searching for one two three four does not trigger the warning, but one two three fo does.

Proposed resolution

Refactor the above code to use arrays instead of strings for the extra data. I attempted to work out a patch for this, but it seems that the extra field is pretty rigid. A more advanced join method may need to be used to fix the issue.

Remaining tasks

Determine how resolve and submit patch.

User interface changes

None.

API changes

None.

Data model changes

None?

Comments

wells created an issue.