Error reported for anonymous users!
inspiredbylife - May 15, 2005 - 03:20
| Project: | Weekly Archive by Node Type |
| Version: | 4.6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
I'm getting the following error when an anonymous user clicks on any "weekly node listing" links:
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 'WHERE (na.grant_view = 1 AND CONCAT(na.realm, na.gid) IN ('all0 query: SELECT DISTINCT(n.nid) from node n where (n.created >= 1112245200) and (n.created <= 1112846399) AND (n.status = 1) WHERE (na.grant_view = 1 AND CONCAT(na.realm, na.gid) IN ('all0','node_privacy_byrole_role1','node_privacy_byrole_user0')) ORDER BY n.created DESC in /home/{user}/public_html/includes/database.mysql.inc on line 66.

#1
This may be some db_rewrite_sql typo errors. I encounter the same problem, here is the code of the patch to apply against the latest cvs (sorry I can't submit an attachment while drupal doesn't want any of my uploaded file - don't know why ? -) copy this code to a file and apply it as usual. It works for me, so hope it could help. Regards, eric.
PS: the code has also some cleanup I made for me i.e some empty line more or less !
--- ./week.module 2005-04-03 04:01:25.000000000 +0200
+++ ./week_mod.module 2005-05-15 21:17:27.180300832 +0200
@@ -1,5 +1,6 @@
<?php
/* $Id: week.module,v 1.8 2005/04/02 20:53:29 prometheus6 Exp $ */
+
global $_week_config;
function week_help($section) {
@@ -56,7 +57,6 @@
}
function _week_block_params($param_array){
-
$output = $param_array['node_type'] ? $param_array['node_type'] != 'node' ? 'type = "'.$param_array['node_type'].'"':"":'';
$output .= !empty($output)&&!empty($param_array['user_no'])? ' AND ':'';
$output .= $param_array['user_no'] ? 'uid = '.$param_array['user_no'] :'';
@@ -149,18 +149,17 @@
}
}
-
function _weekly_contentQuery($query_year, $query_month, $query_day, $param_array){
$start_date = mktime(0,0,0, $query_month, $query_day, $query_year);
$end_date = mktime(23, 59, 59, $query_month,($query_day + 6), $query_year);
$sql_selector = _week_block_params($param_array);
// create the SQL for the query
- $query_info[0] = db_rewrite_sql('SELECT n.nid from {node} n where (n.created >= '.$start_date.') and (n.created <= '.$end_date.') AND (n.status = 1)');
+ $query_info[0] = db_rewrite_sql('SELECT n.nid FROM {node} n WHERE (n.created >= '.$start_date.') AND (n.created <= '.$end_date.') AND (n.status = 1)');
$query_info[0] .= $sql_selector ? ' AND '.$sql_selector:'';
$query_info[0] .= ' ORDER BY n.created '. ($_week_config['week_rev_pagesort'] ? 'ASC' : 'DESC');
$query_info[1] = $start_date;
$query_info[2] = $end_date;
- $query_info[3] = db_rewrite_sql('SELECT COUNT(n.nid) from {node} n where (n.created >= '.$start_date.') and (n.created <= '.$end_date.') AND (n.status = 1)');
+ $query_info[3] = db_rewrite_sql('SELECT COUNT(n.nid) FROM {node} n WHERE (n.created >= '.$start_date.') AND (n.created <= '.$end_date.') AND (n.status = 1)');
return $query_info;
}
@@ -261,4 +260,5 @@
'access' => user_access('access content'));
return $items;
}
-?>
\ Pas de fin de ligne à la fin du fichier.
+
+?>
#2
The error is definitely created by db_rewrite_sql().
Since I'm not having the problem, I need to ask you to look at the top of drupal/includes/database.inc to see which version of the file you have. Look for a line like this:
$Id: database.inc,v 1.37 2005/01/31 20:45:10 dries Exp $And ed: the only changes I see in your patch is getting rid of blank lines and capitalizing SQL key words. Are you saying you had the same problem with this module and that solved it?
#3
Prometheus6, thanks for your answer, here what you requested :
// $Id: database.inc,v 1.39.2.1 2005/04/08 14:24:10 dries Exp $.-> this was for my self ;-)
-> YES, that's it. I Encounter the same trouble here http://drupal.org/node/22664 with an other module, and the fix came from here http://drupal.org/node/22723 ! Your module is now playing nice on my test site :). Regards, Eric.
#4
Thank you, ec. You saved me a lot to time. I find it interesting that upload.module was patched instead of database.inc. I'm curious about when the regex was changed.
ANyway, I've patched the module for 4.6 and HEAD.