Date filter shows error in view exposed group filter with multiple select option.

Created on 7 July 2022, over 2 years ago
Updated 12 August 2024, 3 months ago

Problem/Motivation

Date views filter (\Drupal\views\Plugin\views\filter\Date) throw a php warning with checked "Allow multiple selections" option.

Warning: Undefined array key "type" in Drupal\views\Plugin\views\filter\Date->acceptExposedInput() (line 128 of core/modules/views/src/Plugin/views/filter/Date.php).

This happens because when the "Allow multiple selections" option is checked the $this->group_info is array.
And this condition in the \Drupal\views\Plugin\views\filter\Date::acceptExposedInput is not enought because $this->group_info['type'] can be an empty and cause a warning:

    if (is_array($this->group_info)) {
        $type = $this->group_info['type'];
    }

Steps to reproduce

  1. Install Drupal standard profile
  2. Edit the default Content view at /admin/structure/views/view/content
  3. Add a "Created" filter
  4. Select "Expose this filter to visitors, to allow them to change it"
  5. Select "Grouped filters"
  6. Set the Grouping 1 label to "Last week", operator to "Is greater than", value type to "An offset from ..." and value "-7 days"
  7. Check "Allow multiple selections"
  8. Press Apply and then Save
  9. Navigate to /admin/content

Proposed resolution

Replace condition in the \Drupal\views\Plugin\views\filter\Date:127
if (is_array($this->group_info)) {
with
if (!empty($this->group_info['type'])) {

🐛 Bug report
Status

Needs work

Version

11.0 🔥

Component
Views 

Last updated about 5 hours ago

Created by

🇺🇦Ukraine dench0

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024