db_rewrite_sql cases SQL warning

jonathan_hunt - August 4, 2008 - 00:37
Project:Avatar Blocks
Version:5.x-1.1
Component:Code
Category:bug report
Priority:normal
Assigned:roopletheme
Status:closed
Description

avatar_blocks.module causes:

user warning: Unknown column 'n.nid' in 'on clause' query: SELECT DISTINCT u.uid, u.name, u.picture, s.timestamp FROM users u INNER JOIN sessions s ON u.uid = s.uid INNER JOIN node_access na ON na.nid = n.nid WHERE (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all') OR (na.gid = 0 AND na.realm = 'og_public'))) AND ( s.timestamp >= 1217799487 AND s.uid > 0 ) ORDER BY s.timestamp DESC LIMIT 0, 10

The query for user's names and pictures is wrapped in a db_rewrite_sql but this generates warnings when uid=0 (i.e. anonymous user).
http://api.drupal.org/api/function/db_rewrite_sql/5

Is db_rewrite_sql required here? My work-around is to remove the db_rewrite_sql

#1

roopletheme - August 4, 2008 - 05:31
Assigned to:Anonymous» roopletheme

My initial thought was that it was required. But let me revisit the code...

#2

roopletheme - August 4, 2008 - 21:15

OK, after a bit of digging and some helpful advice from the #drupal IRC channel, it appears that the db_rewrite_sql statement isn't necessary. What's more, I suspect that this call is behind the problems that we've seen using AvatarBlocks with various node access modules, most notably OG Access. Fix coming...

Thanks for the amazingly specific and helpful post!

#3

roopletheme - August 4, 2008 - 22:36
Status:active» fixed

Fixed in 1.2.

#4

Anonymous (not verified) - August 18, 2008 - 22:42
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.