Problem/Motivation
I want to filter nodes by a publication date range, e.g. 2026-01-01--2026-01-31, using a contextual range filter on "Published on" (published_at, provided by the Publication Date module).
The view returns no results.
DateRange::getDateField() treats a field as a UNIX timestamp only if its name starts with "created" or "changed", or is "login" or "access". All other fields are treated as DateTime strings. published_at is stored as a UNIX timestamp (PublicationDateItem extends TimestampItem), so the query uses DATE_FORMAT() on the raw integer. On MariaDB 10.11 this returns NULL, so no rows match.
The code comment in getDateField() already mentions this limitation.
Steps to reproduce
- Install Publication Date (8.x-2.0-beta8) and Views Contextual Range Filter (8.x-3.0).
- Create a node view with a contextual filter on "Content: Published on".
- At
admin/config/content/contextual-range-filter, convert this contextual filter to a range filter. - Pass a range as argument, e.g.
2026-01-01--2026-01-31. - The view returns no results, although nodes were published in that range.
Proposed resolution
Add published_at to the field names that getDateField() treats as UNIX timestamps, next to login and access.
A more general fix would detect timestamp fields by field type (TimestampItem and subclasses) instead of by name.
Comments