Problem/Motivation
Steps to reproduce:
- Add a date filter to any view (e.g., "Authored on" to the pre-defined
content view).
- Expose the filter and its operator.
- In the preview (or the view itself, after saving) select "is empty" or "is not empty".
- This will have no effect, as internally the "exposed input" is not accepted.
Proposed resolution
This currently fails because \Drupal\views\Plugin\views\filter\Date::acceptExposedInput() doesn't take those two operators into account – if the operator doesn't use 1 value, it automatically assumes it uses two. The two "empty" operators have no values, of course, so the min and max keys the method then proceeds to check will in all likelihood be empty, leading to the incorrect behavior.
To fix this, we should simply explicitly check for "uses two values", too.
Remaining tasks
Review, improve and commit the patch.
User interface changes
None.
API changes
None.
Data model changes
None.
Comments
Comment #2
drunken monkeyHere's the patch, also cleaning up some other mistakes (I'm pretty sure) in this method.
Comment #3
dawehnerLet's not try to remove out of scope changes ... This makes it for example much harder to review the patch.
Comment #4
drunken monkeyOK, then I guess just this?
(Skipping the interdiff, as it would be larger than the patch itself.)
Comment #5
dawehnerThank you!, now we just need to ensure that this functionality works on the longrun ... sorry :(
Comment #7
id.tarzanych commentedThanks, Thomas!
Patch works for me
Comment #16
drunken monkeyFixed several years ago by #2865344: Exposed date filters 'empty' and 'not empty' are broken.