Impromer use of db_rewrite_sql causes error

Niels Hackius - October 27, 2009 - 23:11
Project:NodeReferrer
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

The i18n module hooking into db_rewrite_sql caused an error suggesting 'n.language' wasn't a proper column for the node table. The attached patch fixes this.

#1

Niels Hackius - October 27, 2009 - 23:14
Status:active» needs review
AttachmentSize
NodeReferrer_616400_1.patch 730 bytes

#2

andypost - October 28, 2009 - 00:59
Status:needs review» fixed

Commited, thanx

#3

andypost - October 28, 2009 - 01:04
Status:fixed» needs work

Are you really sure that l10n need "node" table and not "node2" table?

#4

Niels Hackius - October 29, 2009 - 00:14

I reviewed this and my conclusion is: It depends on the expected return value of nodereferrer_referrers_with_translations() - unfortunately this is not documented:

In my opinion it be node if all nodes, including the original one should be returned.
If the original one should be excluded it should be it should be node2.
This behavior is due to the INNER JOIN in the sql clause which imposes the node2 data on the node data.

i18n attaches a query that might look like this (db_rewrite_sql($query) - default usage)

WHERE (
n.language = 'en'
OR n.language = ''
OR n.language IS NULL
)

The query I debugged with looks like this (here db_rewrite_sql($query,'node') was chosen)

SELECT node2.nid, node2.vid, node2.title FROM node node INNER JOIN node node2 on node2.tnid = node.tnid WHERE (node.language ='en' OR node.language ='' OR node.language IS NULL) AND ( node.nid IN (105,104,103) AND node.tnid > 0 )

#5

andypost - October 29, 2009 - 09:25
Status:needs work» fixed

Suppose we should filter node by language to return all referrers

#6

System Message - November 12, 2009 - 09:30
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.