Links with "Show hierarchy in dropdown" disabled gives "Deprecated function: range(): Passing null to parameter #1"

Created on 17 April 2024, 5 months ago
Updated 3 July 2024, 2 months ago

Problem/Motivation

When using better exposed filter link element with a dropdown based exposed filter, where "Show hierarchy in dropdown" is not chosen a deprecation warning is given:

Deprecated function: range(): Passing null to parameter #1 ($start) of type string|int|float is deprecated i __TwigTemplate_5551d293906ee191c0badd78779f8980->doDisplay()

This originates from twig template "templates/bef-nested-elements.html.twig", line 35, where it tries to loop using variable "new_nesting_level", but "new_nesting_level" is not set, and translated into "null" which the range call in PHP >= 8.1 does not accept any more.

The reason for "new_nesting_level" is not set is because of line 65 in "src/Plugin/better_exposed_filters/filter/Links.php".
The hierarchy option needs to be enabled for "#bef_nested" to be true. But "templates/bef-links.html.twig" still renders links as a nested element (line 20).

Steps to reproduce

Create a view with an exposed filter, like a taxonomy, and do not choose "Show hierarchy in dropdown".
Make this exposed filter use "better exposed formats".

This was tested on PHP 8.3

Proposed resolution

Make sure that default value of new_nesting_level is 0 and not null.

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ› Bug report
Status

Fixed

Version

6.0

Component

Code

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024