We were facing this issue when working on our search view, it's a simple view with only one field exposed for searching in diferent fields of indexed content.

Steps to reproduce: Add a exposed field on a view of type "Fulltext Search", then search for any string.


Here's the full warning:

Warning: array_intersect(): Expected parameter 2 to be an array, string given in Drupal\search_api\Plugin\views\filter\SearchApiFulltext->query() (line 381 of modules/contrib/search_api/src/Plugin/views/filter/SearchApiFulltext.php).
Drupal\search_api\Plugin\views\filter\SearchApiFulltext->query() (Line: 1373)
Drupal\views\ViewExecutable->_build('filter') (Line: 1262)
Drupal\views\ViewExecutable->build() (Line: 390)

I've made a patch that should ignore this warning, as its just a Warning it does not break the functionality.

Comments

Yuri Morato Duarte created an issue. See original summary.

yuri morato duarte’s picture

Added patch

yuri morato duarte’s picture

Issue summary: View changes
drunken monkey’s picture

Component: General code » Views integration
Status: Active » Needs review
StatusFileSize
new1.21 KB

Thanks for reporting this issue.
I can, however, assure you 100% that your steps to reproduce are not sufficient to reproduce the issue. A “Search: Fulltext search“ exposed filter is probably used by 100,000 websites world-wide, and no-one has yet reported this problem. I, too, could not reproduce it.

Could you tell me whether you enabled the “Expose searched fields” option for the filter, and what other form input fields your exposed form contains? Also, what’s the (non-array) value of $this->searchedFields there?

In any case, I do now see that we (for some reason) ignore the “Expose searched fields” option when collecting the searched fields, so there is the theoretical potential for a bug in case a form field’s ID matches the “Expose searched fields” input ID by coincidence. Maybe that’s what’s happening for you.
Please test whether the attached patch fixes the problem for you.

  • drunken monkey committed b64fb90 on 8.x-1.x
    Issue #3221103 by drunken monkey: Fixed small bug in Views fulltext...
drunken monkey’s picture

Status: Needs review » Fixed

Since I think this patch is an improvement regardless, I now committed it.
Please re-open the issue if the problem remains, with more input.

Status: Fixed » Closed (fixed)

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

yuri morato duarte’s picture

Hi I completely forgot to answer you, but the patch did solve my issue. Thanks!