Download & Extend

Impromer use of db_rewrite_sql causes error

Project:NodeReferrer
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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.

Comments

#1

Status:active» needs review
AttachmentSize
NodeReferrer_616400_1.patch 730 bytes

#2

Status:needs review» fixed

Commited, thanx

#3

Status:fixed» needs work

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

#4

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

Status:needs work» fixed

Suppose we should filter node by language to return all referrers

#6

Status:fixed» closed (fixed)

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