I upgraded to 4.7, php5 and mysql5, and I've been getting these errors:

Unknown column 'node.nid' in 'on clause' query: SELECT YEARWEEK(FROM_UNIXTIME(changed),0) AS weekno FROM node n INNER JOIN node_access na ON na.nid = node.nid WHERE (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all') OR (na.gid = 1 AND na.realm = 'node_privacy_byrole_role') OR (na.gid = 0 AND na.realm = 'node_privacy_byrole_user'))) AND n.type IN ('image','page','poll','story') GROUP BY weekno ORDER BY weekno DESC LIMIT 11 in /var/www/therailfan/includes/database.mysql.inc on line 120.

There might be a similar discussion of the problem here: http://drupal.org/node/40763

Any thoughts? Thanks!

CommentFileSizeAuthor
#1 WEEK_REWRITESQL.patch1.37 KBPrometheus6

Comments

Prometheus6’s picture

Assigned: Unassigned » Prometheus6
Status: Active » Fixed
StatusFileSize
new1.37 KB

Well, this case wasn't quite that hairy but I believe I abused db_rewrite_sql() too.

The change was just committed. For folks that want to edit by hand, find the _weekly_contentQuery() function and replace this

  // 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] .= count($nodes_to_include) > 0 ? 'AND n.type IN (' . implode(',', $nodes_to_include) . ') ': '';
  $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] .= count($nodes_to_include) > 0 ? 'AND n.type IN (' . implode(',', $nodes_to_include) . ') ': '';

with this

  $query_info[0] = 'SELECT n.nid FROM {node} n WHERE (n.created >= '.$start_date.') and (n.created <= '.$end_date.') AND (n.status = 1) ';
  $query_info[0] .= count($nodes_to_include) > 0 ? 'AND n.type IN (' . implode(',', $nodes_to_include) . ') ': '';
  $query_info[0] .= 'ORDER BY n.created '. ($_week_config['week_rev_pagesort'] ? 'ASC' : 'DESC');
  $query_info[0] = db_rewrite_sql($query_info[0], 'n', 'nid');
  $query_info[1] = $start_date;
  $query_info[2] = $end_date;
  $query_info[3] = 'SELECT COUNT(n.nid) FROM {node} n WHERE (n.created >= '.$start_date.') AND (n.created <= '.$end_date.') AND (n.status = 1) ';
  $query_info[3] .= count($nodes_to_include) > 0 ? 'AND n.type IN (' . implode(',', $nodes_to_include) . ') ': '';
  $query_info[3] = db_rewrite_sql($query_info[3], 'n', 'nid');
Prometheus6’s picture

Status: Fixed » Closed (fixed)