Closed (fixed)
Project:
modr8
Version:
5.x-2.5
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
24 Jun 2007 at 17:51 UTC
Updated:
21 Feb 2010 at 18:30 UTC
Jump to comment: Most recent file
Hi there,
I just installed the modr8 module and enabled the block. I also checked the settings, but left them alone. I am getting this warning at the top of the page when visiting my site anonymously.
user warning: Unknown column 'n.moderate' in 'where clause' query: SELECT n.nid FROM node_comment_statistics n WHERE ((n.moderate != 1 OR n.uid = 0)) AND ( n.comment_count > 0 ) ORDER BY n.last_comment_timestamp DESC LIMIT 0, 10 in /home/.paws/tgettig/gettig.net/includes/database.mysql.inc on line 172.
The site is http://www.gettig.net
The functionality of the module looks to be just what I am looking for, but this warning is odd. Any pointers in the right direction are appreciated. Thanks!
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | query.patch | 461 bytes | jenlampton |
Comments
Comment #1
pwolanin commentedI think this is due to a bug in a query in Drupal core that has been fixed. Try updating to the latest 5.x:
http://drupal.org/drupal-5.x-dev
Comment #2
Anthony Gettig commentedHi there,
I just unpacked a freshly downloaded archive of drupal core to my site, ran update.php as the first user, but still get the error.
I'm not the most SQL savvy dude, but I took a look at that table structure. In the node_comment_statistics table, there is no column named "moderate". Could I add this field manually? If so, what should the data type be? Should I already have that column?
Comment #3
pwolanin commentedthe point is the table alias in the query, not the table structure. Did you use the link above to download Drupal?
Comment #4
Anthony Gettig commentedAha! I should have read your direction better. I downloaded from the url you posted, installed, ran the db update script, and yep, that did it. No more error message. Thanks a ton!
Comment #5
pwolanin commentedComment #6
(not verified) commentedComment #7
x2222 commentedI'm having this exact same problem with anonymous users only. Can you be more specific as to what I need to upgrade? I have Drupal 5.1, which is almost the newest. If you're suggesting I have to upgrade to 5.2, I'm a little hesitant as this was a fantastico install and I don't want to take any chances, especially with all the modules I have, before I even launch my site. Any ideas? Thank you.
-Could I try using an older version of modr8?
Comment #8
x2222 commentedAnyone have any ideas for this? Is there a supposed database upgrade script that I can run that doesn't involve upgrading my Drupal 5.1 to 5.2?
Comment #9
scott.mclewin commentedI submitted the patch to core that went in for 5.3 to fix this problem. The issue is that a db_rewrite_sql call in the core comment handling code is failing to pass the primary_table and primary_field arguments. These default to "n" and "nid" and assume that the query contains the node table, that the node table is called 'n' and that the nid field on that table is 'nid'.
But the query is for node comment stats and does not contain the node. Modules like modr8 assume that any query where the primary table is named "n" contains a node and then inject additional SQL into the query based on that assumption. Modr8 is not broken here, core is.
If you want to make a local patch open up comment.module and apply the following change (find the line with the -, change it to look like the line with the +)
This should do it for you.
Scott
Comment #10
pwolanin commentedComment #11
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #12
2c commentedI have Drupal 5.10 installed and I'm getting the error:
I'm using 5.x-2.4.
Could this be a Views issue?
Comment #13
jenlamptonThis same issue reappeared in later versions of Drupal core. Not sure if this is a big enough issue to get a patch in, but someone working on comment should probably be aware of it.
Comment #14
jenlamptonOn second look, this appears to be a new issue. The patch to 5.3 got into core and my SQL error:
seems to legitimately be coming from modr8.
I've tracked the problem down to the modr8_db_rewrite_sql function. Apparently it gets called in one instance when $query is an empty string, so the result tacks a where clause on to nothing, which of course, is invalid. My fix: find line 268 in modr8.module and replace
with
No more error!
Jen
Comment #15
jenlamptonPatch attached.
Comment #16
pwolanin commentedhmm, weird - sounds still like maybe a core issue, but looks liek a pretty safe patch.
Comment #17
pwolanin commentedCommitted this fix to Drupal 6.x (HEAD) and DRUPAL-5
Comment #18
pwolanin commented