Every time I create a taxonewsblock on our website I get the following user warning:

user warning: 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 'DISTINCT(n.nid)) FROM term_node tn INNER JOIN node n ON tn.nid = n.nid WHERE tn.' at line 1 query: SELECT COUNT(t DISTINCT(n.nid)) FROM term_node tn INNER JOIN node n ON tn.nid = n.nid WHERE tn.tid = 60 AND n.status = 1 AND tn.nid NOT IN (1231510851,1231510390,1231403310,1231403143,1231317667,1231317057,1231237645,1231234126,1231233918,1231168059,1230895104,1230293661,1229874226,1229501520,1229420232,1229416405,1229415222,1229337828,1229337563,1229337356,1229337034,1229335076,1229334463,1229333747,1229332783,1229332133) LIMIT 0, 1 in /usr/home/neo1327/public_html/includes/database.mysql.inc on line 174.

The taxonewsblock itself appears on screen but on every page I get this user warning?
I'm using the taxonews-5.x-1.x-dev of the taxonews module on a drupal 5 website.

Comments

fgm’s picture

Assigned: Unassigned » fgm
Status: Active » Postponed (maintainer needs more info)

Strange indeed. Can you reproduce it on a clean install ?

tomgoossens’s picture

I've just reproduced it on a clean localhost install. I get the same user waring after I turn on a taxonews block.

fgm’s picture

This is really strange: the error mentions a SELECT DISTINCT, and this construct is not present at all in the Taxonews code.

It looks like some module is implementing hook_db_rewrite_sql and causing db_rewrite_sql to fail. Can you try to disable all non-core modules and see if this still happens ? If it doesn't, reenable one module at a time, to see when the problem reappears. Node access control modules often cause such problems, OG included.

FWIW, the query thus broken appears to be the one in Taxonews::archiveExists(). You can also comment out db_rewrite_sql() in that function, which should be a workaround to avoid the problem caused by the other module, but then of course you won't have complete access control enabled on Taxonews.

fgm’s picture

Category: bug » support

Cannot reproduce: please disable all contrib modules, and check what happens. Usual suspects would be any node access module, including OG.

tomgoossens’s picture

I've disabled all the contrib modules and I keep getting the user waring untill I disable the taxonews module. So I presume the bug is in de taxonewsmodule itself and not in the interaction with other modules???

fgm’s picture

As I said, I am unable to reproduce the error you describe, and taxonews does not include any DISTINCT request, so the error is caused by some other code modifying its requests.

What I suggested was to comment out the db_rewrite_sql() line in Taxonews::archiveExists(). This should remove the problem. If it does, this will confirm the problem is with another module implementing hook_db_rewrite_sql(). If it doesn't, I have absolutely no idea, and I will need (much) more information to help.

fgm’s picture

Status: Postponed (maintainer needs more info) » Fixed

No answer from user after one month. Assuming problem fixed.

Status: Fixed » Closed (fixed)

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

r_nanda_k’s picture

Hi,

I commented db_rewrite_sql() line as you have mentioned. It worked fine for me.

Thanks
Nanda

fgm’s picture

Thanks for your confirmation. Also, remember that by commenting that line, what you do is actually disable access control for that Taxonews block, which potentially means showing terms which *could* be blocked by the access control module you are using.

fgm’s picture

Status: Closed (fixed) » Needs work
Issue tags: +select distinct as distinct bug

Might be fixable in a more general way like other db_rewrite_sql/DISTINCT bugs. Adding tag.

fgm’s picture

Status: Needs work » Fixed

Core issue fixed in 6.16, not yet fixed in 5.22 (patch available at http://drupal.org/node/284392#comment-1773074 ), so today's dev version includes a specific fix in Taxonews to avoid running into the core issue.

Status: Fixed » Closed (fixed)
Issue tags: -select distinct as distinct bug

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