Fixing the spam module mysql_real_escape_string error

Kernaltrap has an excellent Drupal anti-spam module which is used to great effect at the present time on this site. Recently it was set to moderate forum posts (which in Drupal terminology are themselves nodes) and errors started appearing in the watchdog logs every time the cron tasks were run.

mysql_real_escape_string() expects parameter 1 to be string, array given in /usr/home/adam/public_html/includes/ on line 350.


Unknown column 'n.revision_timestamp' in 'where clause' query: SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.moderate, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid,, u.picture, FROM node n INNER JOIN users u ON u.uid = n.uid INNER JOIN node_revisions r ON r.vid = n.vid WHERE n.nid = '835' AND n.vid = '835' AND n.type = 'forum' AND n.status = '0' AND n.created = '1165946854' AND n.changed = '1165946854' AND n.comment = '2' AND n.promote = '0' AND n.moderate = '0' AND n.sticky = '0' AND n.revision_timestamp = '1165946854' AND n.title = 'Merry Christmas Site' AND n.body = '<a href=\"\">xanax</a> \r\n<a href=\"\">phentermine</a> \r\n<a href=\"http://tramadol400.blo in /usr/home/adam/public_html/includes/ on line 121.

There is a quick one line fix to this, and any errors in other modules that might have the same cause. The Drupal function node_delete() expects a node ID (nid) as a parameter. Unfortunately the spam module, in the function spam_delete_node($nid) was trying to pass it an actual node. Simply change it (line 3025 at the time of writing) from:



and all should be well. Or at least it seems to work here...


Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <del> <p>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You may use [acidfree:xx] tags to display acidfree videos or images inline.
  • Images can be added to this post.

More information about formatting options

This question is for testing whether you are a human visitor and to prevent automated spam submissions.
1 + 3 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.