I've just installed the image module, and when I use it with adminstrator priveleges, everything works fine. However, when I use it as a regular user, function db_rewrite_sql is invoked, and in turn invokes node_db_rewrite_sql in a way that seems to damage the query, so that image galleries cannot be used. In particular, when i try to use the image module as a non-administrator, so that db_rewrite_sql modifies the query to include access control, my site is throwing an sql error:
user error: Unknown column 'n.nid' in 'on clause'
query: SELECT t.tid, COUNT(DISTINCT(n.nid)) AS c FROM term_node t INNER JOIN node_access na ON na.nid = n.nid , node n WHERE (na.grant_view = 1 AND CONCAT(na.realm, na.gid) IN ('all0','term_access4','term_access6','term_access7')) AND t.nid = n.nid AND n.status = 1 AND n.type = 'image' GROUP BY t.tid in /var/www/drupal46/includes/database.mysql.inc on line 66.
The erroneous sql query above is the result of a rewrite of the sql query from the image_page function.
Comments
Comment #1
karger commentedI've confirmed that this really is caused by node_db_rewrite_sql. Even the following innocuous sql query:
gets rewritten into invalid sql:
because the 'join' regular expression in node_db_rewrite_sql terminates at the first capital letter following FROM---namely the I of INNER JOIN that brings in the '{node} n' definition that would make n.nid parseable.
Comment #2
karger commentedComment #3
killes@www.drop.org commentedHere's a patch.
Comment #4
codepoet commentedI applied the patch and my site is still generating the errors:
In this case, it's a call from statistics.module being rewritten to include taxonomy_access tables (I presume from node_access via taxonomy module).
Tried 4.6.5 with patched taxonomy module from taxonomy_access on PHP 5/MySQL 5.1 as well as the stock 4.6.5 patched with just the above.
However, turning off taxonomy_access seems to fix this for me.
Comment #5
codepoet commentedI should clarify: turning off taxonomy_access in the taxonomy_access module resolved it, not unloading the module.
Comment #6
chx commentedhttp://drupal.org/node/51850