Warning: Invalid argument supplied for foreach() with Better Exposed Filter & Grouped Filter

Created on 7 January 2022, over 3 years ago
Updated 27 June 2023, almost 2 years ago

Problem/Motivation (Drupal 8.9.x)

I am getting the following error when used Better Exposed Filter and Grouped Filter with checkbox. Warning: Invalid argument supplied for foreach() in Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid->validateExposed() (line 365 of core/modules/taxonomy/src/Plugin/views/filter/TaxonomyIndexTid.php)

Steps to reproduce

Create a view and add an exposed filter (Term field or EntityReference Field) with Grouped Filter option and set Better Exposed Filter for the same field as Single On/Off Checkbox as screenshot attached. Now you will see the checkbox option on the page and when you select the checkbox and submit the form, will cause the error.

๐Ÿ› Bug report
Status

Postponed: needs info

Version

11.0 ๐Ÿ”ฅ

Component
Viewsย  โ†’

Last updated about 7 hours ago

Created by

๐Ÿ‡ฎ๐Ÿ‡ณIndia jeetmail72 Noida

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Should this be reopened based on previous comments? Anyone able to replicate on D10?

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia pameeela

    I've tried to reproduce using the info in the IS on 10.2 and no luck, not seeing any warnings with this config. The steps in #12 are not clear enough to test them. If this is still occurring could someone please update the issue summary with specific steps to reproduce it?

  • Issue was unassigned.
  • Status changed to Active 10 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia pameeela

    Discussed in Slack, will create an MR with a modified fix.

  • Merge request !8725Check that $values is an array โ†’ (Closed) created by pameeela
  • Status changed to Needs review 10 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia pameeela

    Created an MR to add a check that $values is an array. There is no test here because it would be very difficult to come up with one, so hoping it qualifies for an exemption given both the simplicity of the fix and the fact that it is only resolving a warning.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia pameeela

    Crediting @chx for Slack participation.

  • Pipeline finished with Success
    10 months ago
    Total: 581s
    #220174
  • Status changed to Needs work 10 months ago
  • The Needs Review Queue Bot โ†’ tested this issue.

    While you are making the above changes, we recommend that you convert this patch to a merge request โ†’ . Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)

  • Status changed to Needs review 10 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia pameeela

    Hiding patches

  • Status changed to Needs work 10 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Wondering if we the summary could be updated with proposed solution from the slack channel.

  • Status changed to Needs review 10 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia pameeela

    The MR is pretty straightforward but I added a line about the proposed resolution. Not sure if that is what you mean @smustgrave?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Yup just because not everyone is in slack so any discussion there isnโ€™t known

  • Status changed to RTBC 10 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Meant to mark this a few days ago.

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    I read the issue summary, comments and the MR. I see there are no tests, but that is explained in #19. I have not evaluated that with the testing heuristics. A reminder to us all to summary Slack discussions in a comment. There is no indication here why $value is not an array or if that is really a contrib problem.

    Also, trying for a better title. Leaving at RTBC.

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    Better title, I hope.

  • Status changed to Postponed: needs info 8 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    I'm inclined to mark this won't fix as it feels that exposing a single checkbox for a views filter that expects multiple values is not correct.

    i.e. I don't think BEF should allow using a single checkbox for any filter plugin that extends from InOperator

    In addition I don't think the fix is correct. Rather than casting a single value to an array, its just ignoring the value and hence the submitted value will not be seen. So I think that would mean the filter doesn't work at all.

    As maintainer of BEF @smustgrave is there scope for it to prevent assigning a single-value field to a multi-value filter?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    If we can fix in BEF I'm fine with that.

  • Status changed to Closed: won't fix 2 months ago
Production build 0.71.5 2024