Problem/Motivation

When users see "start" and "end" date filters on a View, they think that if they want to see results from March 1, they should enter March 1 for both the start and end dates, but the date filter evaluates these as the same instant instead of 24 hours apart.

Steps to reproduce

Create content with a date value during a certain date (say, noon on March 1) and index it. Search for that content using a date filter set to start and end on that date. The content will not appear because noon on March 1 is not between midnight and midnight on March 1. Now set the end date to March 2, and the content will be found.

Proposed resolution

A patch being developed for the core Views date filter at https://drupal.org/node/2982968 works very nicely to add a day to the max filter if it it submitted without a ":" character. However, this fix is in the getConvertedValues() method of the date filter object, and Search API's extension of the object does not call that method. Perhaps it would be better for compatibility to call the parent method, but I don't fully understand why the decision was made not to use it, so instead I will just add the code into the opBetween() method.

Remaining tasks

submit a patch.

Comments

BenStallings created an issue. See original summary.

benstallings’s picture

Issue summary: View changes
benstallings’s picture

StatusFileSize
new798 bytes
benstallings’s picture

(Incidentally, the patch above also silences a PHP warning that occurs if the value type isn't set. Extra credit)

benstallings’s picture

Status: Active » Needs review
drunken monkey’s picture

Component: General code » Views integration
StatusFileSize
new2.41 KB
new1.78 KB
new2.59 KB

Thanks a lot for posting this issue and providing a patch!
I could reproduce the problem, and indeed it seems clear that this deviates from the expected behavior. Your fix also seems sensible.

What was still missing, though, was a regression test which I have added in the attached patch. I also had a tiny nitpick about code style.
Please test/review and I can commit this.

benstallings’s picture

Thanks for the code style fix. I'm afraid I don't understand how the regression test works, so I'm not qualified to review it. I hope someone else will review it for you.

drunken monkey’s picture

Status: Needs review » Fixed

Well, I guess the regression test not being reviewed is not such a big deal, as long as it works as expected (as proven by the test bot).
So, committed. Thanks a lot again!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.