Hi,

I happened to type url as follows:

http://www.mysite.com/taxonomy/view

and it gives me sql error. I was trying to see if I can see all taxonomies terms becase I am having problem with taxonomy_dhtml's overview page.

I know this url won't work, but it's too bad that it gives out sql error. It is neither user friendly nor safe. Sorry if this looks really bad here. I don't know how should I format this. Hope the moderator can help format it. The error is like this:

user error: You have an error in your SQL syntax near ') AND n.status = '1' GROUP BY n.nid HAVING COUNT(n.nid) = 1' at line 1
query: SELECT n.nid FROM node n LEFT JOIN term_node r ON n.nid = r.nid WHERE r.tid IN () AND n.status = '1' GROUP BY n.nid HAVING COUNT(n.nid) = 1 in /usr/local/apache/htdocs/drupal/includes/database.mysql.inc on line 75.user error: You have an error in your SQL syntax near '' at line 1
query: SELECT  in /usr/local/apache/htdocs/drupal/includes/database.mysql.inc on line 75.user error: You have an error in your SQL syntax near ') AND n.status = '1' GROUP BY n.nid, n.title, n.type, n.created, n.changed, n.ui' at line 1
query: SELECT n.nid, n.title, n.type, n.created, n.changed, n.uid, u.name FROM node n LEFT JOIN term_node r ON n.nid = r.nid LEFT JOIN users u ON n.uid = u.uid WHERE r.tid IN () AND n.status = '1' GROUP BY n.nid, n.title, n.type, n.created, n.changed, n.uid, u.name HAVING COUNT(n.nid) = 1 ORDER BY static DESC, created DESC LIMIT 0, 10 in /usr/local/apache/htdocs/drupal/includes/database.mysql.inc on line 75.

Comments

jb605’s picture

I am using the most recent CVS version downloaded today on Jun 26 about 5:00pm. I have attached_file, org_informations, taxonomy_dhtml, and weblink modules installed. I do have taxonomy module enbled and I have input lots of taxonomoies. I am running in simplified chinese, so all charset are set to gb2312. However, I don't think this matters in this scenario.

My guess is that the system tries to pass /taxonomy/view as regular /taxonomy/view/or/2,3 etc, but didn't see the following parameters, so the SQL statement got error. Maybe there should be a check for this and just return null if some of the required query parameters are missing/null.

Thanks.

Dries’s picture

Gerhard provided a patch for this which found its way to CVS. Marking this "fixed".

jb605’s picture

Title: view /taxonomy/view gives sql error » view /taxonomy gives sql error

I think this still needs to be fixed. I tried to view

/taxonomy

with or without trailing slash, both gives error.

Also, I think it is a good idea to incorporate taxonomy_html or taxonomy_dhtml's overpage function into taxonomy. The taxonomy is a module, it should handle it's own display. Although this might make it more complicate, but to have another module to fulfill the display function of this module instead of it displaying itself, it is kind of bad idea.

From an overall structure's view, a module should handle it's own function just as a node module does. It should have it's own overview function, has it's own box display implementation, own block display implementation, it's own list display implementation, it's own search, etc. The module invoker should then check to see if each module does implement all this, if not, that module should not be invoked during that call.

jb605’s picture

Title: view /taxonomy gives sql error » view /taxonomy/ gives sql error

Sorry, my bad. Try

/taxonomy/

will give sql error, without trailing slash there is no error.

I think the url/query string paser should catch all these kind of trailing slash because it usually means a call with null parameter, if I understand it correctly.

Or, if it is desirable / allowed to have null parameter in some situation, then in all situation where parameter is not allowed null, the program/module should check for null parameter and make appropriate decision.

Dries’s picture

Title: view /taxonomy/ gives sql error » view /taxonomy gives sql error

Accessing http://server/taxonomy/ works for me; no errors but no nodes either. Try http://drupal.org/taxonomy/, for example. What error do you get?

jb605’s picture

Title: view /taxonomy gives sql error » view http://drupal.org/taxonomy/ gives no sql error

Yes, you are right. Viewing http://drupal.org/taxonomy/ gives no error. But my site does give me error, although I have updated taxonomy module. I didn't upgrade my whole site because I am also customizing some other parts, which prevent me from updating very often. I am waiting for the 4.2 and then update. I am pretty sure my version is different from the one runs on your site if you keep updating your version. But I thought only taxonomy.module will affect this behavior. Looks like I am wrong.

My error is like this:

user error: You have an error in your SQL syntax near ') AND n.status = '1' GROUP BY n.nid HAVING COUNT(n.nid) = 1' at line 1
query: SELECT n.nid FROM node n LEFT JOIN term_node r ON n.nid = r.nid WHERE r.tid IN () AND n.status = '1' GROUP BY n.nid HAVING COUNT(n.nid) = 1 in /usr/local/apache/htdocs/drupal/includes/database.mysql.inc on line 75.user error: You have an error in your SQL syntax near '' at line 1
query: SELECT  in /usr/local/apache/htdocs/drupal/includes/database.mysql.inc on line 75.user error: You have an error in your SQL syntax near ') AND n.status = '1' GROUP BY n.nid, n.title, n.type, n.created, n.changed, n.ui' at line 1
query: SELECT n.nid, n.title, n.type, n.created, n.changed, n.uid, u.name FROM node n LEFT JOIN term_node r ON n.nid = r.nid LEFT JOIN users u ON n.uid = u.uid WHERE r.tid IN () AND n.status = '1' GROUP BY n.nid, n.title, n.type, n.created, n.changed, n.uid, u.name HAVING COUNT(n.nid) = 1 ORDER BY static DESC, created DESC LIMIT 0, 10 in /usr/local/apache/htdocs/drupal/includes/database.mysql.inc on line 75.

Thanks.

Anonymous’s picture