Closed (outdated)
Project:
Better Exposed Filters
Version:
7.0.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
17 Jun 2022 at 15:22 UTC
Updated:
30 Apr 2026 at 12:06 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
leandro713 commentedi was on 5.0 version and it worked fine :-/
Comment #3
neslee canil pinto@leandro713 not able to reproduce this issue. Can you add steps to reproduce this, please
Comment #4
leandro713 commentedas i said before, i was using 5.0 with no errors in a exposed form using the
«Sort filter options» option (this is critical)after upgrading to 5.1 version (without doing anything more) i'm gettin the upper stated error.
i'm not making up the error :-)
Comment #5
jacqui.tenderwolf commentedI am also getting this error when I select "Sort filter options".
Message Warning: Undefined array key "" in Drupal\better_exposed_filters\BetterExposedFiltersHelper::sortNestedOptions() (line 186 of /app/web/modules/contrib/better_exposed_filters/src/BetterExposedFiltersHelper.php)
I am using version 5.2.0 in Drupal 9.4.3.
Comment #6
LarsLamberti commentedAny updates here? More info needed? Still experiencing this, BEF 5.2 & Drupal 9.5.1
Comment #7
greenskin commentedConfirmed, we too get this error. Also seeing it in 6.x.
Comment #8
greenskin commentedNote am seeing this when using an exposed taxonomy field with "Show hierarchy in dropdown" enabled. When this hierarchy setting is disabled I'm not seeing the error.
Comment #9
greenskin commentedThe issue seems to stem from relying on the existence of the delimiter to determine current level while also not requiring the filter which includes a "- All -" option (code recognizes this as a level 1 when it should be 0 because of starting with "-"). Patch sets the current level to 0 when the key is "All".
Comment #10
pragna commentedI have applied patch but getting same issue event if I used latest version 6.0.3.
I changed code like below:
Before: $parent[$cur_level] = $flat_options[$prev_key];
After: $parent[$cur_level] = $flat_options[$key];
It is solved issue.
Comment #11
esteinborn commentedExperiencing this issue in 6.0.3.
Specifically with "show hierarchy" checked. And it doesnt matter what I use as the "All" text, even if i use it without dashes, it still throws this error, and even ignores my "All" text replacement...
@pragna did you apply the patch AND make that additional change? or only your change?
Would you be able to roll a patch with your changes so we can RTBC?
Thanks!
Comment #13
keshavv commentedThe solution given in #10 works for me. I have created the patch for the same.
Thank you.
Comment #14
esteinborn commentedWhen I run $key instead of $prev_key, it appends a hyphen to ALL my taxonomy terms in the list. the original patch is the only one that works for me.
Comment #15
esteinborn commentedwriting back here to say the initial patch #9, not the second one does resolve the issue for me in D10 on latest version of BEF 6.0.3.
can someone else test this so we can RTBC?
Comment #16
smustgrave commentedNot able to replicate in 6.0.x are we still seeing this?
Comment #17
smustgrave commentedIf still a problem in 6.0.x please reopen
Comment #18
karenann commented+ Drupal core 10.3.1
+ Better Exposed Filters 6.0.6
+ PHP 8.2.21
I have a nested taxonomy.
Patch 9 did not help. Patch 13 did, so I looked into why.
I am getting the error on 202 of src/BetterExposedFiltersHelper.php in Better Exposed Filters 6.0.6
Warning: Undefined array key "" in Drupal\better_exposed_filters\BetterExposedFiltersHelper::sortNestedOptions() (line 202 of modules/contrib/better_exposed_filters/src/BetterExposedFiltersHelper.php).I see on line 188, before the iteration, prev_key is set to NULL:
$prev_key = NULL;I also see on line 213, which is within each iteration, that prev_key is set to key:
$prev_key = $key;I'm guessing, though I haven't confirmed, that with $prev_key set to NULL, the first iteration of foreach ($flat_options as $key => &$choice) { } is failing when we try to set $parent[$cur_level] to equal $flat_options[$prev_key] because that equates to setting it to $flat_options[NULL];
I'm going to tool around with this and will report back.
Comment #19
karenann commentedThe following edit seems to help. Basically just does a null test. Would love a set of eyes before I roll a patch to submit. It doesn't do an isset to ensure $flat_options[$prev_key] actually exists, but I feel like that's not necessary.
Comment #20
karenann commentedRolling the patch I mentioned in #19.
Comment #21
smustgrave commentedPlease open an MR and check if an issue against 7.0.x
Comment #22
smustgrave commentedCan this be confirmed against 7.0.x please
Comment #23
philipprudloff commentedI'm still seeing this on 7.0.1 with the error
Comment #24
smustgrave commentedComment #25
smustgrave commentedActually need steps to reproduce.
Comment #26
smustgrave commentedFollowing up for steps to reproduce else going to close this one out.
Comment #27
smustgrave commentedComment #28
karenann commentedFor some reason, I wasn't getting alerts of the request for more info.
Since patch #20 has been working for me, honestly, I don't want to bother the maintainers, but thought it'd be good to report back what I've seen.
I'm running Drupal 10.6.3 and better_exposed_filters 6.0.6.
One place I can recreate this is https://www.salemstate.edu/news. In this page, there are two exposed filters on the left; by category and by audience.
The "by audience" is not the problem, the views filter uses the content type's audience field and the field pulls on a flattened taxonomy list.
The "by category" is the problem and here's why, its two-fold. This exposed filter does not use the content type's category field. Instead, it uses "Has taxonomy term" and the vocabulary selected is a nested taxonomy. Both of these factors are required to produce this error in my environment. When I keep "Has taxonomy term" but change the selected Vocabulary to be "audience," which is flat, no error.
When I scrap the whole exposed filter field and try directly using the content type's field_category_tags, it calls in the nested taxonomy list without error.(I'm getting mixed results with that test and am out of time to test.)So, to reproduce this: