Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 Feb 2009 at 06:57 UTC
Updated:
9 Jul 2010 at 00:31 UTC
Current implementation of ensure_query method incorrectly handles situation when base table has multiplу joins with the same table. For example, sutuation when node has userreference field and user want to see both node author and referenced user name (see #369850: Userreference relationships hijack node author field). In such case code in ensure_table method
// If the relationship is the primary table, this actually be a relationship
// link back from an alias. We store all aliases along with the primary table
// to detect this state, because eventually it'll hit a table we already
// have and that's when we want to stop.
if ($relationship == $this->base_table && !empty($this->tables[$relationship][$table])) {
return $this->tables[$relationship][$table]['alias'];
}
will prevent creation of needed joins, always returning the first join. It seems that it is always nessesary to check both table names AND join conditions in order to decide if another join should be created. That means that the abovementioned code can be removed leaving all decision making to the logic further in the method
Comments
Comment #1
frishsticks commentedHave you found any workarounds for this? I'm running into a similar problem (http://drupal.org/node/553688) and do not know quite how to do it without making this patch to the views module--which I am reticent to do, as who knows what weird bugs I could create in the process.
Comment #2
esmerel commentedThis issue is a year old, it's likely either resolved or no longer relevant.