Missing curlies around table names and query style (inner joins)
Hugo Wetterberg - July 24, 2008 - 09:09
| Project: | Similar Nodes |
| Version: | 5.x-1.1 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | needs review |
Description
Curly brackets have been left out at line 137. Critical bug that could wreck multi-site installs.
137c137
< $build_q = 'INSERT INTO {similarnodes} (nid,tid,weight) SELECT n.nid, tn.tid, "%d" as weight FROM node n , term_node tn , term_data dt WHERE n.nid = tn.nid AND tn.tid = dt.tid AND dt.vid = %d';
---
> $build_q = 'INSERT INTO {similarnodes} (nid,tid,weight) SELECT n.nid, tn.tid, "%d" as weight FROM {node} n , {term_node} tn , {term_data} dt WHERE n.nid = tn.nid AND tn.tid = dt.tid AND dt.vid = %d';

#1
Here's a patch to fix this and also to fix the query style. Drupal standard is to use "INNER JOIN" instead of doing joins inside of the WHERE clause.
#2
+1
Though the patch is missing curlies on term_data :)