Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When:
- a filter is added to a view
- the filter is based on multiple date fields
- one or more of the fields comes from the base table (E.g. Node created date for a node view)
- one or more of the fields doesn't come from the base table (E.g. field_data_field_xxxxxxx)
The SQL generated assigns the wrong table to the field that belongs to the base table. E.g. in the example above it will attempt to check field_data_field_xxxxxxx.created which doesn't exist.
This seems to be because of the code in date_views_filter_handler.inc not properly resetting $this->related_table_alias. (Note: The order in which the fields are processed will affect reproducing of this bug since it will only trigger if the base table field is processed after the non-base table field - not sure what controls that?)
Patch to follow.
Comment | File | Size | Author |
---|---|---|---|
#7 | no-results-when-multiple-dates-included-in-views-filter-2072679-d8.diff | 850 bytes | leewillis77 |
#1 | no-results-when-multiple-dates-included-in-views-filter-2072679-2.diff | 850 bytes | leewillis77 |
Comments
Comment #1
leewillis77 CreditAttribution: leewillis77 commentedPatch attached. This resolves the error for me.
Comment #3
leewillis77 CreditAttribution: leewillis77 commented#1: no-results-when-multiple-dates-included-in-views-filter-2072679-2.diff queued for re-testing.
Comment #5
leewillis77 CreditAttribution: leewillis77 commentedhttps://drupal.org/node/2077839 has been marked as a duplicate of this.
Comment #6
leewillis77 CreditAttribution: leewillis77 commentedAs far as I can tell the test failures are nothing to do with this patch. Can anyone else confirm?
Comment #7
leewillis77 CreditAttribution: leewillis77 commented[Removed comment, the 8.x branch seems largely irrelevant at this point]
Comment #8
cafuego CreditAttribution: cafuego commented#1: no-results-when-multiple-dates-included-in-views-filter-2072679-2.diff queued for re-testing.
Comment #10
leewillis77 CreditAttribution: leewillis77 commentedHi - as far as I can see the failing tests are nothing to do with this page - they seem to relate directly to date migrations which aren't touched by this patch.
Comment #11
morbiD CreditAttribution: morbiD commentedThe above patch seems to fix the problem for my particular use case ("Content: Last comment time" and "Content: Updated date" in the same date filter).
However, I should probably point out that the
} else {
syntax in the patch doesn't comply with Drupal coding standards which state: "The closing curly should be on a line by itself and indented to the same level as the opening statement."Comment #13
cafuego CreditAttribution: cafuego commentedI've applied the patch and fixed the code style issue. Pushed to 7.x-2.x-dev.