Error when Hierarchical Select in Views with exposed filters
margaridacarvalho - September 26, 2009 - 10:04
| Project: | Hierarchical Select |
| Version: | 6.x-3.x-dev |
| Component: | Code - Taxonomy Views |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | fixed |
Description
When integrated in a view with exposed filters, hierarchical select gives this error after clicking apply button (in page view):
* warning: Invalid argument supplied for foreach() in /Users/margaridacarvalho/mysites/clisb/sites/all/modules/views/includes/handlers.inc on line 680.
* user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 0, 10' at line 5 query: SELECT node.nid AS nid, node.title AS node_title FROM node node WHERE LIMIT 0, 10 in /Users/margaridacarvalho/mysites/clisb/sites/all/modules/views/includes/view.inc on line 755.

#1
You're using the latest development snapshot or CVS HEAD?
#2
I'm using hierarchical select 6.x-3.x-dev.
#3
Of which date? Because it automatically gets regenerated after each commit, but only every 12 hours.
#4
Same problem here.
I'm using the latest development snapshot (2009-Sep-25)
#5
I'm also using the latest development snapshot, 2009-Sep-25.
#6
i have a similar problem. using the .dev from sep 30. i'm getting this error:
warning: array_merge() [function.array-merge]: Argument #2 is not an array in /var/www/html/DDO/sites/all/modules/views/includes/handlers.inc on line 590.
#7
I haven't had the time to look into this. I'll try to do that this weekend.
#8
I have what appears to be a similar error:
warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/content/r/i/c/rickherman1/html/sites/all/modules/Views/includes/handlers.inc on line 590.
Interestingly, it only results when I have more than one exposed filter actually selected as the user would when doing a database lookup. If I only set one query condition, no error results. It does this only when at least one HS controlled exposed filter is set. No error occurs when using a dropdown/show hierarchy control setting for the filter. Even with the error, the resulting query appears to work (I have to do more data testing.) I've tried numerous settings in the HS query control for the filter and it doesn't seem to change anything. At this point, I'm going to use the module since it's so much easier for the user, but just turn the error writing off to the screen. Would be great to get it fixed. I'll join the chorus and say this is a tremendous module, and thanks to Mr. Leers and all who have helped.
I've included the following screenshots:
#9
A few more screenshots/files that may be of help in diagnosing.
#10
Hi, same problem here - see attached file. Thanks for support!
Filburt
#11
Could you please post the line on which an error is being reported?
It's very unlikely you did something wrong, probably it's a relatively hard to reproduce bug in HS Taxonomy Views.
#12
same problem here
#13
Again, could you please post the code on that line in the file?
#14
Sorry, but I don't use the module at the moment.
#15
Hello Wim,
Would you want me to post the lines of the "handlers.inc" file on views folder? It's a file at "views\includes\handlers.inc".
Please let me know what should I do to help you help us!
#16
I know which file it is. But there are many different versions of that file and that's why I need you to tell me to copy/paste that line. Or post the file's CVS version.
Thanks :)
#17
OK Wim here's the code..
Error: warning: array_merge() [function.array-merge]: Argument #1 is not an array in E:\wamp\www\Avertiz\sites\all\modules\views\includes\handlers.inc on line 590.
Code (views function):
/**
* Add a table to the query.
*
* This is an advanced concept; not only does it add a new instance of the table,
* but it follows the relationship path all the way down to the relationship
* link point and adds *that* as a new relationship and then adds the table to
* the relationship, if necessary.
*/
function add_table($join = NULL, $alias = NULL) {
// This is used for lookups in the many_to_one table.
$field = $this->handler->table . '.' . $this->handler->field;
if (empty($join)) {
$join = $this->get_join();
}
// See if there's a chain between us and the base relationship. If so, we need
// to create a new relationship to use.
$relationship = $this->handler->relationship;
// Determine the primary table to seek
if (empty($this->handler->query->relationships[$relationship])) {
$base_table = $this->handler->query->base_table;
}
else {
$base_table = $this->handler->query->relationships[$relationship]['base'];
}
// Cycle through the joins. This isn't as error-safe as the normal
// ensure_path logic. Perhaps it should be.
$r_join = drupal_clone($join);
while ($r_join->left_table != $base_table) {
$r_join = views_get_table_join($r_join->left_table, $base_table);
}
// If we found that there are tables in between, add the relationship.
if ($r_join->table != $join->table) {
$relationship = $this->handler->query->add_relationship($this->handler->table, $r_join, $r_join->table, $this->handler->relationship);
}
// And now add our table, using the new relationship if one was used.
$alias = $this->handler->query->add_table($this->handler->table, $relationship, $join, $alias);
// 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;
}
else {
$this->handler->view->many_to_one_tables[$field] = array_merge($this->handler->view->many_to_one_tables[$field], $this->handler->value);
}
return $alias;
}
function get_join() {
return $this->handler->get_join();
}
Line 590 is exactly this piece of the above code:
$this->handler->view->many_to_one_tables[$field] = array_merge($this->handler->view->many_to_one_tables[$field], $this->handler->value);Please let me know should you need ANYTHING else and I will answer asap.
#18
Same problem, suscribing.
#19
subcribing
#20
The problem seems to be that views expect the handler value to be an array while hs_taxonomy_views_handler_filter_term_node_tid.inc only returns a single value. This problem would only show up if you have multiple exposed taxonomy filters in a view, and one of them is HS. I'm not certain where is the best place to fix this, but this seems to work: at line 216 of hs_taxonomy_views_handler_filter_term_node_tid.inc, replace
return parent::accept_exposed_input($input);with
$rc = parent::accept_exposed_input($input);if ($this->select_type_is_hierarchical_select() && !is_array($this->value)) {
$this->value = array($this->value);
}
return $rc;
#21
@jrao: wow, great find! Thanks!
I've created a patch out of your proposed changes. Others, please review!
#22
WORKING OK !!!
(I have 2 filters, replaced the code lines as jaro offered , did not applied the patch yet)
Thank you jaro and Wim.
#23
Good enough for me. Committed: http://drupal.org/cvs?commit=291402.
Thanks!
#24
I thought I've wiritten here... maybe I dindn't push the Save button.
It worked for me too!
#25
Great, another confirmation, thanks mairav! That means it should now be working for everybody.