Date filters not working in Views
| Project: | Date |
| Version: | 5.x-1.6 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | duplicate |
Jump to:
I have a CCK Content type that contains a start date field and end date field. I am trying to create a view that allows users to pick a from and to date and show all nodes whose start is after the "from" date before the "to" date. I added two filters and exposed them, however, no filtering is being done. The problem seems to occur in date_views.inc: date_views_timestamp_filter_handler The value of $type is 'DATE' which falls to the default block and returns without adding a where clause. If I comment out lines 156 and 159 the where clause gets added and the filter works correctly. I'm not really sure what the function SHOULD do though as the comments are extremely sparse. I will provide any help necessary to get a patch made.

#1
Okay, I looked at the code a little closer and I think I have found a logic error.
if ($field_type == 'int' && (empty($value) || !($value == 'now' || date_is_valid($value, DATE_UNIX)))) {
return;
}
elseif (empty($value) || !($value == 'now' || date_is_valid($value, DATE_ISO))) {
return;
}
break;
Examine the case where $value is a valid ISO date:
In the first if statement $value == 'now' is FALSE and date_is_valid($value, DATE_UNIX) is FALSE
The value is then complimented to become true and the function returns.
I am using the following code on my site and would like to have it reviewed before making a patch.
if (empty($value)) {
return;
}
elseif (!($value == 'now' || date_is_valid($value, DATE_ISO) || date_is_valid($value, DATE_UNIX))){
return;
}
break;
#2
Sorry, used the wrong tags:
Replace
if ($field_type == 'int' && (empty($value) || !($value == 'now' || date_is_valid($value, DATE_UNIX)))) {return;
}
elseif (empty($value) || !($value == 'now' || date_is_valid($value, DATE_ISO))) {
return;
}
break;
With
if (empty($value)) {return;
}
elseif (!($value == 'now' || date_is_valid($value, DATE_ISO) || date_is_valid($value, DATE_UNIX))){
return;
}
break;
#3
This fix works. It didn't before. My client will be using it and seeing if any new problems pop up, but if it's still good for linuxbox and imrook, we should get this fix in. I can also roll a patch against head.
#4
I've been tracking down this bug. The problem occurs when date_sql() in date.inc writes out the interval offset. Verify by removing the interval in a sql statement generated by date_sql().
#5
http://drupal.org/node/190289 was marked as a duplicate of this one.
#6
Hi
Is this patch included in the current release ?
what is the status of this ?
#7
See http://drupal.org/node/277420
I still see the issue although it has been marked as fixed with the latest dev version.
#8
me too still facing the same problem
#9
Marking as duplicate since the issue referenced in #7 is about the same problem and is getting a lot of love right now.