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 enough 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
- Install Drupal standard profile
- Edit the default Content view at /admin/structure/views/view/content
- Add a "Created" filter
- Select "Expose this filter to visitors, to allow them to change it"
- Select "Grouped filters"
- Set the Grouping 1 label to "Last week", operator to "Is greater than", value type to "An offset from ..." and value "-7 days"
- Check "Allow multiple selections"
- Press Apply and then Save
- 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'])) {
| Comment | File | Size | Author |
|---|---|---|---|
| #36 | Screenshot 2026-07-13 at 1.22.36 PM.png | 125.45 KB | smustgrave |
Issue fork drupal-3294700
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
dench0Comment #3
dench0Comment #5
dench0Comment #6
eleonelI was able to reproduce the issue and your fix solves the problem for me.
Comment #7
eleonelPatch for
10.0.xbranch.Comment #8
lendudeNice find.
Something similar was happening in #2811887: Exposed date filter leads to a notice, we should add test coverage here too.
Comment #10
alison**maybe** duplicate of #3178117: Views exposed group filter (with option allow multiple selections) generates notices when using date and date range fields ?
Comment #12
bharath-kondeti commentedMade few changes on top of the MR. I will update the test cases as well.
Comment #14
abhinand gokhala k commentedPatch of #11
Comment #15
jodavidson commentedAfter applying the patch of #7 (which fixed the 'type' issue, well done.) I found this error:
Warning: Undefined array key "value" in Drupal\views\Plugin\views\filter\Date->acceptExposedInput() (line 153 of /var/www/html/web/core/modules/views/src/Plugin/views/filter/Date.php)Looking into the code it seems that $operators[$operator]['values'] can be 1 without $this->value['value'] being set.
Perhaps we can add an isset test to the if statement in this block like:
I'm suggesting this as a todo for you, as you already have the code and the existing patch available to you for tweaking. If it's preferable for me to try putting the combined patch together I can give it a shot. I hope this isn't too much of an imposition on your time.
Comment #17
phthlaap commentedThis issue happened on my end; this is the view I tested: test_expose_date_filter.yml or please see my screenshot
Comment #19
phthlaap commentedComment #20
phthlaap commentedI applied a patch and added a test case for this issue.
Comment #22
smustgrave commentedRemoving tests tag as coverage appears to be there.
Left some comments on the MR but proposed solution doesn't match the MR
Comment #23
adriancidComment #24
dieterholvoet commentedThe proposed fix here overlaps with the one in #3389478: Views exposed filter warnings on Date filter min & max.
Comment #26
littlecodingI have another use case that triggers PHP warning here.
Steps to reproduce
Install Drupal standard profile
Note: This may or may not require Search API and an index including the date field used by this filter.
Proposed resolution
Replace condition in the \Drupal\views\Plugin\views\filter\Date:155 (give or take a few lines in dev)
if (!empty($this->options['expose']['use_operator']) && !empty($this->options['expose']['operator_id'])) {with
Again, this just a PHP warning that has only really started being flagged in PHP 8.
Comment #30
baluertlComment #35
nicrodgersI've created a new MR that merges in to main, and brought everything up to date. I've hidden the older MRs for clarity.
Comment #36
smustgrave commentedVerified the bug on the latest main branch, following the steps in the summary.
Applying the MR the error does go away.
Test-only shows the issue (can't run in pipeline)
Left a few questions and summary proposed solution doesn't line up perfectly. Can that be cleaned up please
Looks super close.