Query negation throws error in SearchApiSubscriber.php

Created on 10 January 2024, 10 months ago

Problem/Motivation

Error thrown with a query negation.

Warning: Array to string conversion in Drupal\google_tag\EventSubscriber\SearchApiSubscriber->onSearch() (line 61 of modules/contrib/google_tag/src/EventSubscriber/SearchApiSubscriber.php).
Drupal\google_tag\EventSubscriber\SearchApiSubscriber->onSearch(Object, 'search_api.processing_results', Object)
call_user_func(Array, Object, 'search_api.processing_results', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'search_api.processing_results') (Line: 624)

Query with normal value is handled as a string:

 array:2 [▼
  "#conjunction" => "AND"
  0 => "salt"
]

Negation query flows through as an array

 array:2 [▼
  "#conjunction" => "AND"
  0 => array:3 [▼
    "#negation" => true
    "#conjunction" => "AND"
    0 => "salt"
  ]
]

Steps to reproduce

1. Install Search API and create server and index
2. Install and configure GTM
3. Run a negation query: example ?query=-salt

Proposed resolution

Handle negation queries

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇺🇸United States jimconte

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

Comments & Activities

Production build 0.71.5 2024