Problem/Motivation

Hi!
I see warning message on a search_api view edit page when the facets_exposed_filters is enabled.

Warning: foreach() argument must be of type array|object, null given in facets_exposed_filters_search_api_query_alter() (line 49 of modules/contrib/facets/modules/facets_exposed_filters/facets_exposed_filters.module).

Steps to reproduce

Enable facets_exposed_filters.
Try to edit some search_api view and save some setting.

Proposed resolution

Improve condition in the facets_exposed_filters_search_api_query_alter() to check if $views->filter is not empty.

Issue fork facets-3505164

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

khiminrm created an issue. See original summary.

khiminrm’s picture

khiminrm’s picture

attaching patch for the 3.0.0 with the fix and condition from 3.0.x-dev

khiminrm’s picture

Status: Active » Needs review
chrisolof’s picture

I also ran into this issue and the provided patch appears to fix it. Thanks khiminrm!

mxr576 made their first commit to this issue’s fork.

mxr576’s picture

There is a simpler way to handle potential null

andreasderijcke’s picture

Status: Needs review » Reviewed & tested by the community

MR works nicely.

johan_vm’s picture

I also tested this in our projects and the MR solves the issue. I've added a patch based on the MR.

dasginganinja’s picture

Status: Reviewed & tested by the community » Needs work

After installing this patch my Drupal site renders become unusable.

I am using this for a date field and wanted to expose the counts. We are using Better Exposed Forms with the link widgets and I am pretty sure the change from `select` to `markup` is causing an issue there.

<em class="placeholder">Warning</em>: Undefined array key "#name" in <em class="placeholder">template_preprocess_bef_links()</em> (line <em class="placeholder">215</em> of <em class="placeholder">modules/contrib/better_exposed_filters/includes/better_exposed_filters.theme.inc</em>).

Before I see those errors repeated (assuming for each link in the facet) I do see this error as well:
<em class="placeholder">Warning</em>: Undefined array key "#name" in <em class="placeholder">better_exposed_filters_theme_suggestions_alter()</em> (line <em class="placeholder">45</em> of <em class="placeholder">modules/contrib/better_exposed_filters/includes/better_exposed_filters.theme.inc</em>).

I hope this helps. I think it is gonna need more work so existing sites don't get broken if it comes in.

I am *all* for this functionality coming in, if possible!

sonfd’s picture

Hiding the patch from #10 that is the same as the MR.

loopy1492’s picture

The patch is working for me. The null errors have stopped on view save.

I am not using the functionality in #11, however.

rupertj’s picture

Status: Needs work » Reviewed & tested by the community

@dasginganinja - Are you sure you commented on the right issue? Your comment "I am pretty sure the change from `select` to `markup` is causing an issue there." doesn't match the content of this issue's MR, which is just defaulting a property to an array when it's null.

I'm setting this back to RTBC as the patch fixes the issue for me and others and doesn't seem like it could possibly have any side effects.

strykaizer’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

strykaizer’s picture

Issue tags: +DevDaysAthens2026
kuldeepbarot’s picture

MR is merged to 3.0.x, however I am still facing the same issue, and applying the patch from https://www.drupal.org/project/facets/issues/3505164#comment-15978475 worked. Hence, created this new patch for facets v3.0.2.

strykaizer’s picture

Status: Fixed » Needs work
strykaizer’s picture

Status: Needs work » Needs review
laura.gates’s picture

Status: Needs review » Reviewed & tested by the community

#18's re-roll for v3.0.2 works for me.

strykaizer’s picture

Status: Reviewed & tested by the community » Needs work

I can not reproduce this myself. Anyone who can tell me which drupal version/facets version I need to reproduce, and which steps?

laura.gates’s picture

@strykaizer, I was able to reproduce with 11.2.x converting from the facets 2.0 standard to the ajax facets 3.0 standard.