Wrong join added to the query when i18n is enabled

flobruit - May 30, 2009 - 02:07
Project:Views Calc
Version:6.x-1.3
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

Here's how to reproduce the problem:

Create a views_calc field with %node.nid as its value.
Create a node view with the views_calc field that you created.
The following query is generated:

SELECT node.nid AS nid,
   (node.nid) AS cid2
FROM node node

Now enable the core "content translation" module. The generated query is now:

SELECT node.nid AS nid,
   (node.nid) AS cid2
FROM node node
LEFT JOIN node node2 ON node.tnid = node2.tnid

What happens is that when the content translation module is enabled, the join data from translation.views.inc is used and you end up with a gazillion rows because of the extra join.

This is most likely a bug in views and would appear in any module that tries to do a $query->add_table('node') twice with the content translation module enabled, but I'm posting it here since it really appears in a views_calc context.

#1

hansrossel - October 28, 2009 - 08:02

I can confirm this. Also the SUM is multiplied by the number of languages, so 3 languages gives a sum that is 3 times the expected value.

 
 

Drupal is a registered trademark of Dries Buytaert.