Date 6.x-2.4 maybe broke CCK date Views2 filter

yakker - September 17, 2009 - 18:11
Project:Date
Version:6.x-2.4
Component:Date API
Category:support request
Priority:normal
Assigned:Unassigned
Status:needs review
Description

My apologies if this is in the wrong section. I upgraded to Date 6.x-2.4 today, along with the core update to Drupal (6.14). I have a view which filters on a CCD date field. The filter now evaluates incorrectly. It worked fine yesterday, and this update is the only thing I've done since, so I wondered if it was a Date issue.

The filter compares two CCK date fields, linked with OR, to the current date, and returns any nodes for which that CCK date field is greater than 'now'. There are many nodes in the database for which this should evaluate to true, and I have confirmed this be getting rid of the filter and taking a look at the date that displays through the $content variable. Setting the granularity in the view filter made no difference to whether anything showed up. The two dates being compared have different granularities set in their CCK settings, but previously this was no problem (I'm testing for day, and both have at least day in their CCK settings).

The view's SQL is below. I wondered if it was the STR_TO_DATE that was the problem, due to that "T" being appended despite the granularity settings in the view filter. Anyway - again, apologies if this is in the wrong place. It just cropped up today immediately after updating to 6.x-2.4. Any help is very much appreciated!

Chris

SELECT DISTINCT(node.nid) AS nid, node.created AS node_created, term_data.weight AS term_data_weight, node_data_field_art_news_sub_deadline.field_art_news_sub_deadline_value AS node_data_field_art_news_sub_deadline_field_art_news_sub_deadline_value FROM node node  LEFT JOIN term_node term_node ON node.vid = term_node.vid LEFT JOIN term_data term_data ON term_node.tid = term_data.tid LEFT JOIN content_field_art_news_dates node_data_field_art_news_dates ON node.vid = node_data_field_art_news_dates.vid LEFT JOIN content_type_art_news node_data_field_art_news_sub_deadline ON node.vid = node_data_field_art_news_sub_deadline.vid WHERE ((term_data.vid in ('2')) AND (node.status <> 0)) AND (

//The area in question...

(DATE_FORMAT(STR_TO_DATE(node_data_field_art_news_dates.field_art_news_dates_value2, '%Y-%m-%dT%T'), '%Y-%m-%d') >= '2009-09-17')
OR
(DATE_FORMAT(STR_TO_DATE(node_data_field_art_news_dates.field_art_news_sub_deadline_value, '%Y-%m-%dT%T'), '%Y-%m-%d') >= '2009-09-17')

) ORDER BY node_created DESC, term_data_weight ASC, node_data_field_art_news_sub_deadline_field_art_news_sub_deadline_value DESC

#1

yakker - September 17, 2009 - 18:20
Title:Upgrade to Date 6.x-2.4 broke all date-filters in Vie» Date 6.x-2.4 maybe broke CCK date Views2 filter

I just went back to version 2.3, and my date filters are working fine again. But looking at the SQL for the query, it is identical, so I'm guessing the query isn't the issue. Anyone else experiencing this?

#2

arlinsandbulte - September 17, 2009 - 22:34

Might be related to, or a duplicate of this: #385688: Views filters & arguments not working when using a date relationship.
Not real sure if it is a duplicate, so I will just leave status alone for now.

#3

oggsmith - September 18, 2009 - 16:21

Edit: - my post duplicates/relates to #580178: Views: SQL Error "Unknown column" when using fields from different content-types in a filter
Edit: - Original posters issue may be different

Same/Similar issue here - views break with Date 6.x-2.4, work fine when reverting to 2.3
The SQL from the view does change:

(DATE_FORMAT(STR_TO_DATE(node_data_field_vc3.field_vc3_value, '%Y-%m-%dT%T')

in the working version changes to

(DATE_FORMAT(STR_TO_DATE(node_data_field_date.field_vc3_value, '%Y-%m-%dT%T')

in the broken version.

field_vc3 being the Field name.

#4

oggsmith - September 18, 2009 - 16:22

Edit: - my post duplicates/relates to #580178: Views: SQL Error "Unknown column" when using fields from different content-types in a filter
Edit: - Original posters issue may be different

Changing line 413 of includes/date_api_filter_handler.inc

From:

$query_field['field']['fullname'] = $this->table_alias. '.' .$field['field_name'];

to:

$query_field['field']['fullname'] = $query_field['field']['table_name']. '.' .$field['field_name'];

Fixes my issue.

#5

yakker - September 21, 2009 - 16:23

Thanks oggsmith - looks like it's probably the same issue for me, but I haven't gone in to check. Will update as soon as I do. In the meantime, anyone on the project want to comment on whether this needs a patch?

#6

leinado - October 19, 2009 - 03:43

Thanks, oggsmith - this worked for me, too.

#7

pauldawg - October 19, 2009 - 14:14

oggsmith, #4 solved a huge issue for me as well: #592796: Date Filters not working in Views when multiple date fields are used. Thank you! Hoping to get a reviewed patch into the next build.

#8

yakker - October 21, 2009 - 18:10

Fix works for us too - thanks again, oggsmith!

#9

pauldawg - November 9, 2009 - 01:44

Update: the same fix in #4 which worked on my local installation does not work on my Development server. Not sure what the difference is, or what the error was (Internal Server Error, 500). I am on a shared hosting package so it will take me 24 hours before I can get my server logs enabled, but I thought I'd put this out there in case anyone else has experienced the same?

#10

joostvdl - November 12, 2009 - 12:00
Status:active» needs review

Patch #4 works

Can somebody add this to the development tree?

#11

seren10pity - November 17, 2009 - 09:43
 
 

Drupal is a registered trademark of Dries Buytaert.