I'm running the latest CVS update of Drupal 4.6 RC (as of 23 MAR 2005), and I'm getting the following database error when an Anonymous user access my site, and the comment block is NOT populated with the latest comment links.

user error: Unknown table 'n' in on clause
query: SELECT DISTINCT(c.nid), c.* FROM comments c  INNER JOIN node_access na ON na.nid = n.nid WHERE  (na.grant_view = 1 AND CONCAT(na.realm, na.gid) IN ('all0','node_privacy_byrole_role1','node_privacy_byrole_user0')) AND  c.status = 0 ORDER BY c.timestamp DESC LIMIT 0, 10 in /opt/lampp/htdocs/includes/database.mysql.inc on line 66.

Once a user is authenticated, everything works fine. I've poked around the code some, and I'm pretty sure that "n.nid" should be "c.nid", but that is not getting built by the sql query builder (possibly in node.module). The comment block generation function in comment.module is passing a 'c' argument to the query builder, but whatever is building the query seems to be ignoring that argument and using 'n' instead.

I'm trying to dig and understand how this code works, but I need a little help. Thanks!

CommentFileSizeAuthor
#1 node_access_alias.patch526 byteschx

Comments

chx’s picture

Assigned: Unassigned » chx
StatusFileSize
new526 bytes

Here is the fix.

timothy bennett’s picture

Actually, I had tested this fix on my own as I was exploring my problem. It would seem like this patch doesn't fix my problem, but unfortunately it doesn't. I'm digging some more...

timothy bennett’s picture

Would the node_privacy_byrole module be affecting this somehow... I do have this module switched on, even though it hasn't been *officially* ported to 4.6 yet.

chx’s picture

Please elaborate on what's your problem now. I have just checked, and the query is rewritten properly, in the ON clause we have c.nid as there should be. Do you get an SQL error still? Or just the functionality is not there?

timothy bennett’s picture

Hmmmmm... must've been a browser cache thing. After applying the patch last Thurs afternoon, I was getting the same error message as if I hadn't even applied the patch. Went home, didn't work Good Friday or the weekend, and everything is fine today. No error message. Chalk it up to a cached page...

chx’s picture

Well, the patch is in and Timothy says it's OK. So, I am setting this issue fixed.

Anonymous’s picture