'Preview' button on CCK types gives SQL error from relatedlinks module - looks like it is trying to look at the $node->nid but it doesnt exist because it is a preview.

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 'GROUP BY n.nid ORDER BY count DESC, sticky DESC, created DESC, promote DESC LIMI' at line 1 query: SELECT n.nid, n.title, n.type, n.uid, COUNT(tn.tid) as count, ncs.comment_count FROM node n INNER JOIN term_node tn USING (nid) LEFT JOIN node_comment_statistics ncs USING (nid) WHERE tn.tid IN (tags) AND n.status = 1 AND n.moderate = 0 AND n.nid != GROUP BY n.nid ORDER BY count DESC, sticky DESC, created DESC, promote DESC LIMIT 5 in /home/dgtlmoon/workspace/ultramet/includes/database.mysql.inc on line 121.

see attached patch

CommentFileSizeAuthor
related-links-node.patch972 bytesdgtlmoon
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dgtlmoon’s picture

also another issue around line 970 it does not wrap the terms in "'s so you get another sql error

Unknown column 'tags' in 'where clause' query: SELECT n.nid, n.title, n.type, n.uid, COUNT(tn.tid) as count, ncs.comment_count FROM node n INNER JOIN term_node tn USING (nid) LEFT JOIN node_comment_statistics ncs USING (nid) WHERE tn.tid IN (tags) AND n.status = 1 AND n.moderate = 0 AND n.nid != 2620 GROUP BY n.nid ORDER BY count DESC, sticky DESC, created DESC, promote DESC LIMIT 5

+++ relatedlinks.module (working copy)
@@ -965,7 +965,12 @@
   }

   if (count($tids) > 0) {
-    $str_tids = implode(',', $tids);
+    // wrap each tid in quotes
+    foreach($tids as $t) {
+      $stids[] = "'$t'";
+    }
+    $str_tids = implode(',', $stids);
+
     $where[] = 'tn.tid IN ('. $str_tids .')';
     if (!empty($node_types)) {
       $where[] = "n.type IN ('". implode("', '", $node_types) ."')";
Zen’s picture

dgtlmoon: I don't really have time to maintain the 4.7 branch. If you'd like to maintain it, please let me know and I'll assign you as a co-maintainer.

Thanks mate,
-K

DuaelFr’s picture

Status: Needs review » Closed (won't fix)

This version of Related links is not supported anymore. The issue is closed for this reason.
Please upgrade to a supported version and feel free to reopen the issue on the new version if applicable.

This issue has been automagically closed by a script.