The module reports error in SQL syntax, when you try to access My Interests for the 1st time
| Project: | Interests |
| Version: | 5.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Игорь |
| Status: | duplicate |
Jump to:
Right after install when I use the module for the first time, i.e. accessing My Interests (appears in the Navigation menu after the module installation), I see the following:
user warning: 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 ') AND i.uid != '1' AND i.uid != '0' AND u.uid = i.uid AND i.tid query: SELECT i.uid, i.tid, u.name, t.name AS tname FROM interests i, users u, term_data t WHERE () AND i.uid != '1' AND i.uid != '0' AND u.uid = i.uid AND i.tid = t.tid GROUP BY i.uid ORDER BY i.counter desc LIMIT 10 in D:\htdocs\VirtualHosts\mybiz2\includes\database.mysql.inc on line 167.
Source code analysis gave the following diagnosis: when the module tries to build a list of users with the same interests as mine, the situation when I don't have any interest yet is not taken into account (see empty brackets after WHILE in the SQL request?).
The function is interests_browse(). Lines 198 through 204:
$myTags = db_query("SELECT i.tid FROM {interests} i WHERE i.uid = '%s'", $user->uid);
while($row = db_fetch_array($myTags)){
$like .= "i.tid = '".$row['tid']."' OR ";
}
$like = rtrim($like, ' OR ');
$resultUsers = db_query("SELECT i.uid, i.tid, u.name, t.name AS tname FROM {interests} i, {users} u, {term_data} t WHERE ($like) AND i.uid != '%s' AND i.uid != '0' AND u.uid = i.uid AND i.tid = t.tid GROUP BY i.uid ORDER BY i.counter desc LIMIT 10", $user->uid);
See suggested patch in attachment.
| Attachment | Size |
|---|---|
| interests.module_1.patch | 417 bytes |

#1
See http://drupal.org/node/142224
#2
Oh and i added the error check in too :) Not exactly your patch as i'd already made other changes, but it does what it needs to do.