I get this error when I enable the module

user error: 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 ') AND n.status = 1 ORDER BY sticky DESC, created DESC LIMIT 10'
query: SELECT DISTINCT(n.nid), n.title, n.body FROM term_node t INNER JOIN node n ON t.nid = n.nid WHERE t.tid IN () AND n.status = 1 ORDER BY sticky DESC, created DESC LIMIT 10 in /customers/masys.se/masys.se/httpd.www/includes/database.mysql.inc on line 66.

Anders E

CommentFileSizeAuthor
#1 taxonomy_block.patch951 bytesdonalm

Comments

donalm’s picture

Title: user error:.... » user warning
StatusFileSize
new951 bytes

After enabling taxonomy_block I had the following error for users other than Admin.

user warning: Unknown column 'n.nid' in 'on clause' query: SELECT DISTINCT(n.nid), n.title, r.body, sticky, created FROM term_node t INNER JOIN node_access na ON na.nid = n.nid INNER JOIN node n ON t.nid = n.nid INNER JOIN node_revisions r ON r.vid = n.vid WHERE (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all') OR (na.gid = 2 AND na.realm = 'term_access'))) AND t.tid IN (6,7,4) AND n.status = 1 ORDER BY sticky DESC, created DESC LIMIT 12 in /Library/WebServer/share/drupal48/includes/database.mysqli.inc on line 125.

This reminded me of: http://drupal.org/node/46864.

The query seems to be written in such a way that db_rewrite_sql breaks it. The following revised query works for me:

$nodes = db_query(db_rewrite_sql(
'SELECT 
    DISTINCT(n.nid), 
    n.title, 
    r.body, 
    sticky, 
    created 
FROM 
    {term_node} t,
    {node} n 
INNER JOIN 
    {node_revisions} r 
ON 
    r.vid = n.vid 
WHERE 
    t.nid = n.nid AND
    t.tid IN (%s) AND 
    n.status = 1
ORDER BY 
    sticky DESC, 
    created DESC 
LIMIT %d'
), implode(array_keys($tids), ','), $result->length);

I've attached a patch for current CVS of taxonomy_block.module. I'm new to Drupal, so I may well have done something brain-dead. I'd appreciate review from someone who knows the platform.

silurius’s picture

Just bumping because I seem to have stumbled across this one too.

drewish’s picture

Status: Active » Postponed (maintainer needs more info)

could you roll a patch with the differences?

drupalnesia’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

Upgrade to 6.x version. Thanks.