Hello,

I just tried the Hierarchical Select module to enhance my views 2 taxonomy filters, and got the following error when I try to enable "Display the node count" or "Require associated node".

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 '***CURRENT_USER***) LEFT JOIN flag_content flag_content_node_1 ON node.nid = fl' at line 3 query: SELECT COUNT(*) FROM (SELECT DISTINCT(node.nid) AS nid FROM node node LEFT JOIN flag_content flag_content_node ON node.nid = flag_content_node.content_id AND (flag_content_node.fid = 1 AND flag_content_node.uid = ***CURRENT_USER***) LEFT JOIN flag_content flag_content_node_1 ON node.nid = flag_content_node_1.content_id AND (flag_content_node_1.fid = 3 AND flag_content_node_1.uid = ***CURRENT_USER***) LEFT JOIN flag_content flag_content_node_2 ON node.nid = flag_content_node_2.content_id AND (flag_content_node_2.fid = 2 AND flag_content_node_2.uid = ***CURRENT_USER***) INNER JOIN term_node term_node ON node.vid = term_node.vid LEFT JOIN content_field_image node_data_field_image ON node.vid = node_data_field_image.vid LEFT JOIN history history_user ON node.nid = history_user.nid AND history_user.uid = ***CURRENT_USER*** INNER JOIN node_comment_statistics node_comment_statistics ON node.nid = node_comment_statistics.nid LEFT JOIN flag_content flag_content ON node.nid = flag_content.content_id AND (flag_content.fid = 2 AND flag_content.uid = ***CURRENT_USER***) LEFT JOIN flag_content flag_content2 ON node.nid = flag_content2.content_id AND (flag_content2.fid = 3 AND flag_content2.uid = ***CURRENT_USER***) LEFT JOIN flag_content flag_content3 ON node.nid = flag_content3.content_id AND (flag_content3.fid = 1 AND flag_content3.uid = ***CURRENT_USER***) LEFT JOIN content_type_video node_data_field_date ON node.vid = node_data_field_date.vid WHERE term_node.tid = 99 ) count_alias in /dev/sites/all/modules/hierarchical_select/modules/hs_taxonomy_views.module on line 529.

There are actually lots of errors, but they seem to be similar in nature.

The view works totally fine, though it is quite complex with various filters and relationships.

Best,
Andrey.

Comments

mr.andrey’s picture

Title: SQL error near '***CURRENT_USER*** » SQL error near '***CURRENT_USER*** on "Display the node count" or "Require associated node".

(settings a more accurate title)

So troubleshooting... the error seems to come from this line in hs_taxonomy_views.module:

$count[$current_view->name][$item] = db_result(db_query($count_query, $args));

For some reason $count_query's ***CURRENT_USER*** doesn't get replaced with the user id.

Adding this right before makes the errors go away, and everything function as intended:

global $user;
$count_query = str_replace("***CURRENT_USER***", $user->uid, $count_query);

The above is not really a solution, it just shows the cause of the problem.

Andrey.

pochota’s picture

Version: 6.x-3.x-dev » 6.x-3.3
Status: Active » Needs work

This bug is still active. Please, fix it for a new release.

Thanks.

mr.andrey’s picture

I ended up writing my own solution to display only the terms that are used.

wim leers’s picture