There was a user warning being generated when the author_facet view was displayed for anonymous or non-administrator users. I tracked down the error in author_facet.module in the latest snapshot:

// $Id: author_facet.module,v 1.9 2008/01/30 16:16:59 davidlesieur Exp $

On line 199 there is a missing ')' after the 'IN' clause:

$query->add_where('NOT EXISTS (SELECT users_roles.rid FROM {users_roles} users_roles WHERE users.uid = users_roles.uid AND users_roles.rid IN ('. implode(', ', $this->_excluded_roles) .'))');

should be:

$query->add_where('NOT EXISTS (SELECT users_roles.rid FROM {users_roles} users_roles WHERE users.uid = users_roles.uid AND users_roles.rid IN ('. implode(', ', $this->_excluded_roles) .')))');

Here's a patch (not that it's _really_ needed):

--- /home/bagdanov/projects/drupal/faceted_search/author_facet.module 2008-01-30 16:16:59.000000000 +0000
+++ /var/www/html/kcews/modules/faceted_search/author_facet.module 2008-01-31 15:28:01.000000000 +0000
@@ -196,7 +196,7 @@
$query->add_field('users', 'name');
$query->add_groupby('users_uid');
if (count($this->_excluded_roles)) {
- $query->add_where('NOT EXISTS (SELECT users_roles.rid FROM {users_roles} users_roles WHERE users.uid = users_roles.uid AND users_roles.rid IN ('. implode(', ', $this->_excluded_roles) .'))');
+ $query->add_where('NOT EXISTS (SELECT users_roles.rid FROM {users_roles} users_roles WHERE users.uid = users_roles.uid AND users_roles.rid IN ('. implode(', ', $this->_excluded_roles) .')))');
}
return TRUE;
}

Cheers,

-Andy

Comments

David Lesieur’s picture

Status: Active » Postponed (maintainer needs more info)

Hi Andy,

Are you sure about this? I'm counting 4 opening parentheses and 5 closing ones in your patch.

I'm also not able to get the warning. Is it a SQL or PHP issue? If it is SQL, then you might have a stray opening parenthese somewhere in the query, but the culprit does not seem to be on the above line. We'd have to look at the whole query.

Helmut Neubauer’s picture

Hi,

I have the same problem. I think it's a problem of using Facet Search and i18n at the same time. The warning doesn't occur if the i18n module is disabled. Here the full warning:

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 'GROUP BY users_uid ASC ORDER BY count DESC, users_name ASC LIMIT 0, 11' at line 1 query: SELECT DISTINCT(n.nid) AS nid, COUNT(DISTINCT(n.nid)) AS count, users.uid AS users_uid, users.name AS users_name FROM node AS n INNER JOIN users AS users ON n.uid = users.uid LEFT JOIN i18n_node i18n ON n.nid = i18n.nid WHERE (i18n.language ='de' OR i18n.language ='' OR i18n.language IS NULL) AND ( ((n.status = 1) AND (users.status = 1) AND (NOT EXISTS (SELECT users_roles.rid FROM users_roles users_roles LEFT JOIN i18n_node i18n ON n.nid = i18n.nid WHERE (i18n.language ='de' OR i18n.language ='' OR i18n.language IS NULL) AND ( users.uid = users_roles.uid AND users_roles.rid IN (5)))) ) GROUP BY users_uid ASC ORDER BY count DESC, users_name ASC LIMIT 0, 11 in /var/www/drupal/includes/database.mysql.inc on line 172.
David Lesieur’s picture

Status: Postponed (maintainer needs more info) » Active

Mmmh... Looks like i18n might have trouble with the subquery when it inserts its language filter into the query. As a workaround, you could avoid the subquery altogether by excluding no roles from the author facet.

Then to fix the bug, we'll probably have to insert subqueries only after hook_db_rewrite_sql() has been called on other modules.

David Lesieur’s picture

Note that this may be as trivial as calling faceted_search_query's add_subquery() method instead of using add_where() as is currently the case.

David Lesieur’s picture

Assigned: Unassigned » David Lesieur
Status: Active » Fixed

Just committed the above solution. Please re-open this issue if the problem persists.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.