After I updated from 2.6 to 2.7 I noticed that some of my views were broken, specifically the views that use a summary sort as the default action when an argument is not present. I tracked it down to a change in date_api_argument_handler.inc from #385688: Views filters & arguments not working when using a date relationship.. It fixes my problem to comment out the change that was made in that patch, but obviously that patch fixed someone else's problem so that is not a generally valid solution.
To replicate, create a view of nodes with cck date fields. Add a Date: Date (node) argument. Set the action to take if the argument is not present to 'summary, sorted descending'. Check the box next to the date field. The defaults should work for everything else.
The update drops the left join from the query, so this:
SELECT DATE_FORMAT(STR_TO_DATE(node_data_field_event_date.field_event_date_value, '%Y-%m-%dT%T'), '%Y') AS node_data_field_event_date_field_event_date_value, COUNT(node.nid) AS num_records
FROM node node
LEFT JOIN content_type_site_event node_data_field_event_date ON node.vid = node_data_field_event_date.vid
WHERE (node.type in ('site_event')) AND (node.status <> 0)
GROUP BY node_data_field_event_date_field_event_date_value
ORDER BY node_data_field_event_date_field_event_date_value DESC
Becomes this:
SELECT DATE_FORMAT(STR_TO_DATE(node_data_field_event_date.field_event_date_value, '%Y-%m-%dT%T'), '%Y') AS node_data_field_event_date_field_event_date_value, COUNT(node.nid) AS num_records
FROM node node
WHERE (node.type in ('site_event')) AND (node.status <> 0)
GROUP BY node_data_field_event_date_field_event_date_value
ORDER BY node_data_field_event_date_field_event_date_value DESC
And that does not work.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | date-DRUPAL-6--2_datefield_summary.patch | 852 bytes | dboulet |
| #1 | date-summary-argument-broken.patch | 9.18 KB | b-prod |
Comments
Comment #1
b-prod commentedThe table is not added to the Views query queue. It only misses the following code:
$this->ensure_my_table();in the summary_query() method.The patch below corrects this. And also corrects lots of extra spaces (because of my editor settings which removes extra spaces).
If you really need a patch without spaces modifications, tell me and I will create another patch.
Comment #2
gilgabar commentedThat did not resolve the problem.
Comment #3
dboulet commentedVery frustrating bug. Patch in #1 did not fix it for me either.
Comment #4
dboulet commentedThis workaround works for me.
Comment #5
gilgabar commentedThat patch works for me as well. Thanks.
Comment #6
ari-meetai commentedI confirm this works here too with latest dev. Thank you.
Comment #7
kdebaas commentedPatch helped me too
Comment #8
chadchandler commentedI thought I was going crazy. This patch isn't included with the latest dev release is it?
Comment #9
Ecio commentedI think I'm experiencing the same problem: i had one view that was used to create a grouped by year (cck field) summary and it started returning no results after the update (thus making the relative block disappear).
I'll try the patch hoping it will be fixed soon in the recommended version.
EDIT: Patch works, thanks dboulet!
Comment #10
mattcasey commentedI just tried and got this error using 2.7 and 2.x dev releases, however the patch to 2.7 works.
Comment #11
b0b commentedsubscribe
Comment #12
bettibio commentedI have applied the patch in #4 to 2.x dev and it's work for summaryze argument (cck data field) in view block display but when click on link i get this error:
* user warning: Unknown column 'node_data_field_dataemissione.field_dataemissione_value' in 'where clause' query: SELECT COUNT(*) FROM (SELECT node.nid AS nid FROM node node WHERE ((node.status <> 0) AND (node.type in ('circolari'))) AND ((DATE_FORMAT(STR_TO_DATE(node_data_field_dataemissione.field_dataemissione_value, '%Y-%m-%dT%T'), '%Y-%m') <= '2011-01' AND DATE_FORMAT(STR_TO_DATE(node_data_field_dataemissione.field_dataemissione_value, '%Y-%m-%dT%T'), '%Y-%m') >= '2011-01')) ) count_alias in D:\xampp\htdocs\fermicecina\sites\all\modules\views\includes\view.inc on line 745.
* user warning: Unknown column 'node_data_field_dataemissione.field_dataemissione_value' in 'where clause' query: SELECT node.nid AS nid, node.created AS node_created FROM node node WHERE ((node.status <> 0) AND (node.type in ('circolari'))) AND ((DATE_FORMAT(STR_TO_DATE(node_data_field_dataemissione.field_dataemissione_value, '%Y-%m-%dT%T'), '%Y-%m') <= '2011-01' AND DATE_FORMAT(STR_TO_DATE(node_data_field_dataemissione.field_dataemissione_value, '%Y-%m-%dT%T'), '%Y-%m') >= '2011-01')) ORDER BY node_created DESC LIMIT 0, 10 in D:\xampp\htdocs\fermicecina\sites\all\modules\views\includes\view.inc on line 771.
Comment #13
karens commentedThe patch works correctly for me and apparently most others. The problem in #12 must have some other factor involved and should be reported in its own issue.
Comment #14
Super Druper commentedfixed
Comment #15
karens commentedThe last issue is a totally different issue that the subject of this issue. The summary is fixed. Reporting other things here will not get them addressed. This is not an issue where you can dump anything that you think is broken about argument summaries. Each problem goes in its own issue so it can be addressed and marked fixed.
Comment #16
Super Druper commentedThis is just an extension of the same issue stemming from the argument summary that was addressed in the original post. However, if you're so adamant about placing it under a separate subject heading then no problem. I'll post it as a new issue.
Comment #17
bohz commentedThe fix in #4 works well.
Thanks a lot!