user warning: Unknown column 'n.type' in 'where clause' query: SELECT nc.nid FROM node_comment_statistics nc LEFT JOIN drigg_node dn2 ON dn2.dnid = n.nid WHERE ( 1=1 AND !(n.type='drigg' AND dn2.killed=1 ) ) AND ( nc.comment_count > 0 ) ORDER BY nc.last_comment_timestamp DESC LIMIT 0, 10 in /var/www/dailyradical.org/htdocs/includes/database.mysqli.inc on line 151.

Comments

rek2’s picture

Category: bug » support
mercmobily’s picture

Category: support » bug
Status: Active » Closed (fixed)

Hi,

This is a bug, and it needs to get fixed.
Can you please let me know exactly how to reproduce it?

It's possibly because of my poor skills in using hook_db_rewrite_sql (which I use to "hide" killed nodes).

I did some initial research. My rewrite only happens when the primary field is "n" (node) (see drigg.module, line 97):

if($primary_table='n' && $primary_field == 'nid'){

The only query I could find in Drupal that matches your warning is on line 252 of comment.module:

$result = db_query_range(db_rewrite_sql("SELECT nc.nid FROM {node_comment_statistics} nc WHERE nc.comment_count > 0 ORDER BY nc.last_comment_timestamp DESC", 'nc'), 0, $number);

[10 minutes later]

AAAAAAAAAHHHHHHHHHHHHHHHHHHHHHH!!!!!!!!!

Found the bug. I can't believe I had missed it. I just can't.

if($primary_table='n' && $primary_field == 'nid'){

That "=" needs to be == !!!!!!!

This is funny. This is the sort of mistakes a 1st year CS student would make...

My apologies everybody. Fixed in the latest drigg distribution. I will soon (I promise, very soon) commit Drigg's code to Drupal.

Bye,

Merc.

P.S.
It's also fixed in CVS

mercmobily’s picture

Status: Closed (fixed) » Fixed

Hi,

Sorry, since it's fixed... marking it as fixed

Merc.

rek2’s picture

Thanks!!

Cheers

Anonymous’s picture

Status: Fixed » Closed (fixed)

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