From 8ba24397e6b64f69603a3983c40baa2186e821b0 Mon Sep 17 00:00:00 2001 From: solotandem Date: Wed, 8 May 2013 01:25:05 +0000 Subject: [PATCH] Issue #1989588: Respect the filter group when excluding values on many-to-one filters. --- includes/handlers.inc | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/includes/handlers.inc b/includes/handlers.inc index 2a33d5d..a7cfe10 100644 --- a/includes/handlers.inc +++ b/includes/handlers.inc @@ -834,11 +834,12 @@ class views_many_to_one_helper { // Store what values are used by this table chain so that other chains can // automatically discard those values. - if (empty($this->handler->view->many_to_one_tables[$field])) { - $this->handler->view->many_to_one_tables[$field] = $this->handler->value; + $group = $this->handler->options['group']; + if (empty($this->handler->view->many_to_one_tables[$group][$field])) { + $this->handler->view->many_to_one_tables[$group][$field] = $this->handler->value; } else { - $this->handler->view->many_to_one_tables[$field] = array_merge($this->handler->view->many_to_one_tables[$field], $this->handler->value); + $this->handler->view->many_to_one_tables[$group][$field] = array_merge($this->handler->view->many_to_one_tables[$group][$field], $this->handler->value); } return $alias; @@ -860,17 +861,18 @@ class views_many_to_one_helper { $options = $this->handler->options; $view = &$this->handler->view; $query = &$this->handler->query; + $group = $options['group']; if (!empty($options['require_value'])) { $join->type = 'INNER'; } - if (empty($options['add_table']) || empty($view->many_to_one_tables[$field])) { + if (empty($options['add_table']) || empty($view->many_to_one_tables[$group][$field])) { return $query->ensure_table($this->handler->table, $this->handler->relationship, $join); } else { - if (!empty($view->many_to_one_tables[$field])) { - foreach ($view->many_to_one_tables[$field] as $value) { + if (!empty($view->many_to_one_tables[$group][$field])) { + foreach ($view->many_to_one_tables[$group][$field] as $value) { $join->extra = array( array( 'field' => $this->handler->real_field, @@ -895,7 +897,8 @@ class views_many_to_one_helper { // We hence get the absolute simplest: $field = $this->handler->relationship . '_' . $this->handler->table . '.' . $this->handler->field; if ($this->handler->operator == 'or' && empty($this->handler->options['reduce_duplicates'])) { - if (empty($this->handler->options['add_table']) && empty($this->handler->view->many_to_one_tables[$field])) { + $group = $this->handler->options['group']; + if (empty($this->handler->options['add_table']) && empty($this->handler->view->many_to_one_tables[$group][$field])) { // query optimization, INNER joins are slightly faster, so use them // when we know we can. $join = $this->get_join(); @@ -903,13 +906,13 @@ class views_many_to_one_helper { $join->type = 'INNER'; } $this->handler->table_alias = $this->handler->query->ensure_table($this->handler->table, $this->handler->relationship, $join); - $this->handler->view->many_to_one_tables[$field] = $this->handler->value; + $this->handler->view->many_to_one_tables[$group][$field] = $this->handler->value; } else { $join = $this->get_join(); $join->type = 'LEFT'; - if (!empty($this->handler->view->many_to_one_tables[$field])) { - foreach ($this->handler->view->many_to_one_tables[$field] as $value) { + if (!empty($this->handler->view->many_to_one_tables[$group][$field])) { + foreach ($this->handler->view->many_to_one_tables[$group][$field] as $value) { $join->extra = array( array( 'field' => $this->handler->real_field, -- 1.7.10.4