Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.0-rc1
Component:
Views Data
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
2 Oct 2008 at 17:48 UTC
Updated:
14 Apr 2009 at 13:44 UTC
Hi,
We have a view which uses a term id as an argument to filter on. Nothing especially unusual. The arguments handler code looks like this:
$handler->override_option('arguments', array(
'tid' => array(
'default_action' => 'ignore',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => '',
'default_argument_type' => 'fixed',
'default_argument' => '',
'validate_type' => 'taxonomy_term',
'validate_fail' => 'ignore',
'break_phrase' => 0,
'add_table' => 0,
'require_value' => 0,
'reduce_duplicates' => 0,
'set_breadcrumb' => 0,
'id' => 'tid',
'table' => 'term_node',
'field' => 'tid',
'relationship' => 'none',
'default_options_div_prefix' => '',
'default_argument_user' => 0,
'default_argument_fixed' => '',
'default_argument_php' => '',
'validate_argument_node_type' => array(
'poll' => 0,
'image' => 0,
'feed' => 0,
'feed_item' => 0,
'tellafriend_node' => 0,
'bestbuy' => 0,
'contact_ifa' => 0,
'correspondence' => 0,
'feature' => 0,
'feedback' => 0,
'fivestar' => 0,
'guide' => 0,
'interview' => 0,
'news' => 0,
'page' => 0,
'press_release' => 0,
'promotion' => 0,
'provider' => 0,
'report' => 0,
'research' => 0,
'story' => 0,
'tools' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(
2 => 2,
4 => 0,
5 => 0,
),
'validate_argument_type' => 'tid',
'validate_argument_php' => '',
'override' => array(
'button' => 'Override',
),
),
));
When no argument is supplied, the executed query looks like this:
SELECT DISTINCT(node.nid) AS nid,
node_comment_statistics.comment_count AS node_comment_statistics_comment_count,
node.created AS node_created,
node.title AS node_title,
users.name AS users_name,
users.uid AS users_uid,
users.picture AS users_picture
FROM node node
INNER JOIN term_node term_node ON node.vid = term_node.vid
LEFT JOIN node_comment_statistics node_comment_statistics ON node.nid = node_comment_statistics.nid
INNER JOIN boston_shared.users users ON node.uid = users.uid
WHERE (node.status <> 0) AND (node.type in ('feed_item', 'feature', 'interview', 'news', 'press_release', 'report', 'research')) AND (term_node.tid IN (107, 105))
ORDER BY node_created DESC
But as soon as you pass an argument representing a term ID within the selected vocabulary (in this case vid = 2) then you get this weird additional join in the query which explicitly excludes term 105:
LEFT JOIN term_node term_node2 ON node.vid = term_node2.vid AND term_node2.tid != 105
No matter what the term ID is, if the criteria above are met then this join will appear in the query and block term 105. Very odd! :-/
Comments
Comment #1
merlinofchaos commentedI'd have to see the entire view. When combining an argument and a filter both on terms, this is very much the intended behavior, though. It specifically excludes previous terms in the new join. And before you suggest it, no, it can't modify the WHERE clause from the original filter, the two handlers are not able to interact in that fashion.
Comment #2
greg.harveyAh, there is a term filter too. In fact, now you mention it I'm not sure why! Possibly legacy. I don't think it is actually used for anything, so could be removed. I still don't know how it manages to pull that same TID, 105, no matter what the arguments are. Perhaps the term filter is set to something by default and we're just seeing that?
Anyway, this may be enough of a pointer to allow me to sort this out. Thanks.
If I'm still struggling, I'll post the whole view tomorrow (don't have the code handy).
Comment #3
greg.harveySwitching to a support request, since I now suspect this is not a bug at all.
Comment #4
greg.harveyOk, removing the filter worked, but I still don't quite get why this filter code works the way it does. I'm sure it's perfectly logical, but I don't see it.
We exposed the filter simply as an easy way to get a handle on the term names, so we can remove it and get them another way. Our view path is "insights" and it has a Term ID argument, so if I pass it TID 107, e.g. "insights/107", or just plain 107 on the Views UI page, I get this query back:
I just don't get why it excludes term 105, regardless of previous selections. I don't understand why this would be happening. It's not in the view code or anything like that, and term 105 is not the previous selection - the previous selection was All.
Full view code is here:
Comment #5
domesticat commentedClosed while closing all Views support requests with no activity for 6 months. If you still need help, you may re-open this issue at any time.