summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEarl Miles2009-09-15 15:52:39 (GMT)
committer Earl Miles2009-09-15 15:52:39 (GMT)
commit022d1541097f28bdf6863d832f4564548e6d7d07 (patch)
tree067b3a2ed2f07771d4ead9cab0b003a8e90b676b
parentdb73598e6c6cb39f2726577478878a9d15ff17e7 (diff)
#333439 by killes: Fix query for multiply inherited taxonomy terms with taxonomy filter.
-rw-r--r--CHANGELOG.txt3
-rw-r--r--modules/taxonomy/views_handler_argument_term_node_tid_depth.inc36
2 files changed, 22 insertions, 17 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index c0721a3..d7616a7 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -24,7 +24,8 @@ Views 2.x-dev
o #537870 by dww: Fixed a bug in the [uplodate_fid-size] token where format_size() was called on it twice.
o #510910 by mfb: Fixed bug where multiple fields sharing a column in a table was broken so only the final field would display.
o #546586 by dww: Fixed bugs that prevented '0' being a valid rewrite text or empty text for a view field. Also fixes a logic bug regarding the handling of the 'Count the number 0 as empty' setting.
- o #507884 by TheRec: Removed matching title (alt) attribute on node links.
+ o #507884 by TheRec: Removed matching title (alt) attribute on node links.\
+ o #333439 by killes: Fix query for multiply inherited taxonomy terms with taxonomy filter.
Other changes:
o Implement a post_render hook (for themes too) and cache method.
diff --git a/modules/taxonomy/views_handler_argument_term_node_tid_depth.inc b/modules/taxonomy/views_handler_argument_term_node_tid_depth.inc
index aec1c23..779c165 100644
--- a/modules/taxonomy/views_handler_argument_term_node_tid_depth.inc
+++ b/modules/taxonomy/views_handler_argument_term_node_tid_depth.inc
@@ -89,31 +89,35 @@ class views_handler_argument_term_node_tid_depth extends views_handler_argument
$placeholder = "= %d";
$tids = array($this->argument);
}
- $subquery = "\n SELECT tn.vid FROM {term_node} tn\n";
- $where = " WHERE tn.tid $placeholder\n";
- $args = $tids;
- $last = "tn";
+
+ $node_table = $this->ensure_my_table();
+ $group = 'term_node_nid_depth';
+ $this->query->set_where_group('OR', $group);
+
+ // Create a new join to relate the 'term_node' table to our current 'node' table.
+ $join = new views_join;
+ $join->construct('term_node', $node_table, 'vid', 'vid');
+ $term_node = $this->query->add_relationship('term_node', $join, $node);
+ $this->query->add_where($group, "$term_node.tid $placeholder", $tids);
if ($this->options['depth'] > 0) {
- $subquery .= " LEFT JOIN {term_hierarchy} th ON th.tid = tn.tid\n";
- $last = "th";
+ $th_join = new views_join;
+ $th_join->construct('term_hierarchy', $term_node, 'tid', 'tid');
+ $term_hierarchy = $this->query->add_relationship('term_hierarchy', $th_join, $term_node);
foreach (range(1, abs($this->options['depth'])) as $count) {
- $subquery .= " LEFT JOIN {term_hierarchy} th$count ON $last.parent = th$count.tid\n";
- $where .= " OR th$count.tid $placeholder\n";
- $args = array_merge($args, $tids);
- $last = "th$count";
+ $th_join = new views_join;
+ $th_join->construct($term_hierarchy, $term_hierarchy, 'parent', 'tid');
+ $term_hierarchy = $this->query->add_relationship($term_hierarchy, $th_join, $term_hierarchy);
+ $this->query->add_where($group, "$term_hierarchy.tid $placeholder", $tids);
}
}
else if ($this->options['depth'] < 0) {
foreach (range(1, abs($this->options['depth'])) as $count) {
- $subquery .= " LEFT JOIN {term_hierarchy} th$count ON $last.tid = th$count.parent\n";
- $where .= " OR th$count.tid $placeholder\n";
- $args = array_merge($args, $tids);
- $last = "th$count";
+ $th_join->construct($term_hierarchy, $term_hierarchy, 'tid', 'parent');
+ $term_hierarchy = $this->query->add_relationship($term_hierarchy, $th_join, $term_hierarchy);
+ $this->query->add_where($group, "$term_hierarchy.tid $placeholder", $tids);
}
}
-
- $this->query->add_where(0, "$this->table_alias.$this->real_field IN ($subquery$where )", $args);
}
function title() {