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.
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | facets_exposed_filters-fix-error-on-views-edit-page-3505164-18-3.0.2.patch | 831 bytes | kuldeepbarot |
Issue fork facets-3505164
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
Comment #2
khiminrm commentedComment #3
khiminrm commentedattaching patch for the 3.0.0 with the fix and condition from 3.0.x-dev
Comment #4
khiminrm commentedComment #5
chrisolofI also ran into this issue and the provided patch appears to fix it. Thanks khiminrm!
Comment #8
mxr576There is a simpler way to handle potential null
Comment #9
andreasderijckeMR works nicely.
Comment #10
johan_vm commentedI also tested this in our projects and the MR solves the issue. I've added a patch based on the MR.
Comment #11
dasginganinjaAfter 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!
Comment #12
sonfdHiding the patch from #10 that is the same as the MR.
Comment #13
loopy1492 commentedThe patch is working for me. The null errors have stopped on view save.
I am not using the functionality in #11, however.
Comment #14
rupertj commented@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.
Comment #15
strykaizerComment #17
strykaizerComment #18
kuldeepbarot commentedMR 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.
Comment #19
strykaizerComment #20
strykaizerComment #21
laura.gates#18's re-roll for v3.0.2 works for me.
Comment #22
strykaizerI can not reproduce this myself. Anyone who can tell me which drupal version/facets version I need to reproduce, and which steps?
Comment #23
laura.gates@strykaizer, I was able to reproduce with 11.2.x converting from the facets 2.0 standard to the ajax facets 3.0 standard.
Comment #25
harishstOKay, it looks like this was merged and fixed here: https://git.drupalcode.org/project/facets/-/commit/43b2d1044adf75dd626c6092bdc31e59d9f3e70c
The view no longer shows the warning. Changing the status to "Fixed"; a second pair of eyes would be great.