"Warning: Array to string" when Search API query uses a '-'

Created on 4 January 2024, 8 months ago
Updated 20 February 2024, 7 months ago

Problem/Motivation

I was trying out my newly configured Database search and found that when I used the "-" character, which is used in search to negate one of the search terms, a warning message was produced from google_tag.

I don't know if this has any other negative impact besides failing to log the query.

Steps to reproduce

1. Set up Search API, server, index, and results view
2. Install google tags
3. enter "back -forward" any other combination of words where one of them has a "-" directly before it.
4. your search will work fine, but if you have the same issue as me, you will see this warning message:
Warning: Array to string conversion in Drupal\google_tag\EventSubscriber\SearchApiSubscriber->onSearch() (line 61 of modules\contrib\google_tag\src\EventSubscriber\SearchApiSubscriber.php).

Proposed resolution

  1. Find out the structure and contents of the array which is passed to the 'onSearch()' function when a search query includes a "-"
  2. Adapt the 'onSearch()' function to recombine that array into a string
🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024