Hi,

Taxonomy Filter has been working brilliantly, and continues to do so for authenticated users but the following error message is now appearing for anonymous users:

user warning: Unknown column 'term_data.tid' in 'on clause' query: SELECT DISTINCT td.vid, td.tid, td.name, COUNT(DISTINCT(n.nid)) AS count FROM default_term_data td INNER JOIN default_term_node tn ON tn.tid = td.tid INNER JOIN default_term_node tn0 ON tn.vid = tn0.vid INNER JOIN default_node n ON tn.nid = n.nid LEFT JOIN default_forum_access fa ON term_data.tid = fa.tid LEFT JOIN default_acl acl_fa ON acl_fa.name = term_data.tid AND acl_fa.module = 'forum_access' LEFT JOIN default_acl_user aclu_fa ON aclu_fa.acl_id = acl_fa.acl_id AND aclu_fa.uid = 0 WHERE ((fa.grant_view >= 1 AND fa.rid IN (1)) OR fa.tid IS NULL OR aclu_fa.uid = 0) AND ( td.vid IN (4) AND tn0.tid IN (92) AND n.status = 1 AND n.moderate = 0 )GROUP BY td.vid, td.tid, td.name, td.weight ORDER BY vid, weight, name in /home/civione/www/www/sites/all/modules/taxonomy_filter/taxonomy_filter.module on line 483.

I recently installed Forum Access 6.x-1.5 and ACL 6.x-1.2, which may be creating some kind of issue/conflict? The site is running 6.19 core and Taxonomy Filter 6.x-1.3. Any help would be hugely appreciated (including advice on whether this is actually an issue with ACL or Forum Access).

Thanks very much.
Graham

Comments

solotandem’s picture

Category: bug » support

Looking at the query string, "LEFT JOIN default_forum_access fa ON term_data.tid = fa.tid," it would seem that the query alteration being done by forum_access is not respecting the table prefix of "default" that is on all of the tables.

This would seem to be a forum_access issue.

gmreed’s picture

Title: Conflict with Forum Access and/or ACL modules? » Conflict between Taxonomy Filter and Forum Access (and/or ACL modules)?
Project: Taxonomy Filter » Forum Access
Version: 6.x-1.3 » 6.x-1.5

Okay, thanks. That being the case I am switching this issue to the Forum Access queue.

salvis’s picture

Status: Active » Fixed

In

forum_access_db_rewrite_sql($query, $primary_table, $primary_field, $args)

we have

      $sql['join'] = "LEFT JOIN {forum_access} fa ON $primary_table.tid = fa.tid
                      LEFT JOIN {acl} acl_fa ON acl_fa.name = $primary_table.tid AND acl_fa.module = 'forum_access'
                      LEFT JOIN {acl_user} aclu_fa ON aclu_fa.acl_id = acl_fa.acl_id AND aclu_fa.uid = $user->uid";

Apparently, someone is passing 'term_data' as $primary_table. How, my dear friend, should FA know that you mean 'default_term_data'? If you look at the documentation of db_rewrite_sql(), you'll see that $primary_table ought to receive the table alias, in this case 'td'...

solotandem’s picture

Project: Forum Access » Taxonomy Filter
Version: 6.x-1.5 » 7.x-1.x-dev
Category: support » bug
Status: Fixed » Active

Thanks for pointing out my error in responding too quickly. Was on the right track but jumped to an incorrect conclusion.

solotandem’s picture

Title: Conflict between Taxonomy Filter and Forum Access (and/or ACL modules)? » Table name passed to db_rewrite_sql() not enclosed in brackets
Assigned: Unassigned » solotandem
Status: Active » Fixed

Without brackets, query rewriting by other modules will return an invalid string.

Fixed in 6.x-1.4 release.

salvis’s picture

You do pass 'td', not '{term_data}', right?

solotandem’s picture

No, I passed the latter value.

As you wrote in #3, the documentation of db_rewrite_sql() indicates the $primary_table can be '{term_data}' instead of the "non-standard" table alias of "td" for this table. Given the non-standard alias, it would seem more reliable for someone writing an hook_db_rewrite_sql() to rely on the table name than its alias. In general, it would not seem a best practice to rely on an arbitrary abbreviation.

Regardless, as your code relies on the primary field (as does node module), is it not a moot point for you? In absence of a survey of all modules with such a hook function, it is not clear which value is being evaluated to trigger a rewrite. Also, as it seems the module triggering this hook has the choice on what value to pass, does it not also seem the responsibility of the hook function writers to consider both values?

salvis’s picture

You can use whatever alias you want. You're passing in the query and the alias.

If you pass in the table name and one of the hook_db_rewrite_sql() implementations happens to join in the same table again (for whatever reasons), then it'll fail.

gmreed’s picture

Status: Fixed » Active

I have updated to 6.x-1.4 and upon re-enabling Forum Access and ACL received the following error message:

user warning: Unknown column 'default_term_data.tid' in 'on clause' query: SELECT DISTINCT td.vid, td.tid, td.name, COUNT(DISTINCT(n.nid)) AS count FROM default_term_data td INNER JOIN default_term_node tn ON tn.tid = td.tid INNER JOIN default_term_node tn0 ON tn.vid = tn0.vid INNER JOIN default_node n ON tn.nid = n.nid LEFT JOIN default_forum_access fa ON default_term_data.tid = fa.tid LEFT JOIN default_acl acl_fa ON acl_fa.name = default_term_data.tid AND acl_fa.module = 'forum_access' LEFT JOIN default_acl_user aclu_fa ON aclu_fa.acl_id = acl_fa.acl_id AND aclu_fa.uid = 0 WHERE ((fa.grant_view >= 1 AND fa.rid IN (1)) OR fa.tid IS NULL OR aclu_fa.uid = 0) AND ( td.vid IN (4) AND tn0.tid IN (85) AND n.status = 1 AND n.moderate = 0 )GROUP BY td.vid, td.tid, td.name, td.weight ORDER BY td.vid, td.weight, td.name in /home/civione/www/www/sites/all/modules/taxonomy_filter/taxonomy_filter.module on line 534.

As before, upon disabling FA and ACL, Taxonomy Filter works without incident.

(This being the case, I have changed the status of this issue back to 'active' - apologies if I should not have done so for any reason)

solotandem’s picture

Yes, it appears the SQL fails if an aliased table is referenced subsequently by its actual name. So, if you change the db_rewrite_sql() to use 'td' instead of '{term_data} all should be well. Thanks for reporting back.

solotandem’s picture

Status: Active » Fixed

Corrected in 6.x-1.5 release to use the table alias.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.