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.

Comments

b-prod’s picture

Version: 6.x-2.7 » 6.x-2.x-dev
Status: Active » Needs review
StatusFileSize
new9.18 KB

The 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.

gilgabar’s picture

Status: Needs review » Needs work

That did not resolve the problem.

dboulet’s picture

Priority: Normal » Critical

Very frustrating bug. Patch in #1 did not fix it for me either.

dboulet’s picture

Title: argument summary broken » Argument summary in Views is broken
StatusFileSize
new852 bytes

This workaround works for me.

gilgabar’s picture

Status: Needs work » Reviewed & tested by the community

That patch works for me as well. Thanks.

ari-meetai’s picture

I confirm this works here too with latest dev. Thank you.

kdebaas’s picture

Patch helped me too

chadchandler’s picture

I thought I was going crazy. This patch isn't included with the latest dev release is it?

Ecio’s picture

I 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!

mattcasey’s picture

I just tried and got this error using 2.7 and 2.x dev releases, however the patch to 2.7 works.

b0b’s picture

subscribe

bettibio’s picture

I 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.

karens’s picture

Status: Reviewed & tested by the community » Fixed

The 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.

Super Druper’s picture

fixed

karens’s picture

The 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.

Super Druper’s picture

This 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.

bohz’s picture

The fix in #4 works well.

Thanks a lot!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.