Problem/Motivation

Steps to reproduce:

  1. Add a date filter to any view (e.g., "Authored on" to the pre-defined content view).
  2. Expose the filter and its operator.
  3. In the preview (or the view itself, after saving) select "is empty" or "is not empty".
  4. 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

drunken monkey created an issue. See original summary.

drunken monkey’s picture

Status: Active » Needs review
StatusFileSize
new1017 bytes

Here's the patch, also cleaning up some other mistakes (I'm pretty sure) in this method.

dawehner’s picture

Status: Needs review » Needs work

Let's not try to remove out of scope changes ... This makes it for example much harder to review the patch.

drunken monkey’s picture

Status: Needs work » Needs review
StatusFileSize
new535 bytes

OK, then I guess just this?
(Skipping the interdiff, as it would be larger than the patch itself.)

dawehner’s picture

Issue tags: +Needs tests

Thank you!, now we just need to ensure that this functionality works on the longrun ... sorry :(

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

id.tarzanych’s picture

Thanks, Thomas!
Patch works for me

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

drunken monkey’s picture

Status: Needs review » Closed (outdated)