Error thrown if array used in variables when facet does not allow multiple selection

Created on 9 May 2024, 5 months ago
Updated 13 September 2024, 15 days ago

Problem/Motivation

If you have a single select facet view (i.e. Allow multiple selections is not checked) and the url uses variable arrays an error is thrown.
i.e.
/facet-view?category[]=1&category[]=2
vs
/facet-view?category=1

You will get the following error:

TypeError: trim(): Argument #1 ($string) must be of type string, array given in trim() (line 172 of modules/contrib/facets/src/UrlProcessor/UrlProcessorPluginBase.php).

Steps to reproduce

  1. Create a view with exposed facets
  2. Make sure "Allow multiple selections" is unchecked
  3. Alter the url to have array get variables i.e. ?category[]=1&category[]=2
  4. Error is thrown/

Proposed resolution

Check if the value is an array and implode it.
This will at least prevent the error not sure if we want to just select the first from the array instead.

Remaining tasks

Code.

๐Ÿ› Bug report
Status

RTBC

Version

3.0

Component

Code

Created by

๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom 3li U.K. ๐Ÿ‡ฌ๐Ÿ‡ง

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