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.

Comments

imrook’s picture

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;
imrook’s picture

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;
mlncn’s picture

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.

jscheel’s picture

Version: 5.x-1.x-dev » 5.x-1.6

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().

Aren Cambre’s picture

http://drupal.org/node/190289 was marked as a duplicate of this one.

avior’s picture

Hi
Is this patch included in the current release ?
what is the status of this ?

dugh’s picture

See http://drupal.org/node/277420
I still see the issue although it has been marked as fixed with the latest dev version.

Remon’s picture

me too still facing the same problem

Aren Cambre’s picture

Status: Active » Closed (duplicate)

Marking as duplicate since the issue referenced in #7 is about the same problem and is getting a lot of love right now.