- Issue created by @Buelto
When using Better Exposed Filters with sorted filter options, a PHP warning is triggered if one of the options has an empty string ("") as its key. This is a valid use case — for example, to represent a blank/default filter option — and it works functionally (the filter renders correctly and operates as expected), but it throws a warning:
Warning: Undefined array key "" in Drupal\better_exposed_filters\BetterExposedFiltersHelper::sortNestedOptions()
This happens specifically inside the sortNestedOptions() method when trying to access the value of a previous key without validating its existence first.
This warning clutters logs, can affect debugging workflows, and may trigger issues in stricter CI environments or when logging is set to be verbose.
Patch the sortNestedOptions() method in BetterExposedFiltersHelper.php to:
This resolves the warning without changing the module’s behavior or affecting existing filter rendering logic.
Active
7.0
Code