Closed (fixed)
Project:
Activity
Version:
6.x-2.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
22 Apr 2009 at 00:22 UTC
Updated:
6 May 2009 at 00:40 UTC
I created a simple view that shows the user activity. It works for admin but any other user causes the following mysql error:
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 (activity_messages.nid IS NULL OR (na.grant_view >= 1 AND ((na.gid = 0 AND n'
Here's the full query:
SELECT DISTINCT (
activity_messages.amid
) AS amid, activity_messages.everyone_message AS activity_messages_everyone_message, activity_messages.author_message AS activity_messages_author_message, activity_messages.uid AS activity_messages_uid, activity_messages.created AS activity_messages_created, DATE_FORMAT( (
FROM_UNIXTIME( activity_messages.created ) + INTERVAL -14400
SECOND ) , '%Y%m%d%H%i'
) AS activity_messages_created_minute
FROM activity_messages activity_messages
LEFT JOIN node_access na ON na.nid = activity_messages.nid
AND activity_messages.type = 'node'
WHERE (
AND (
activity_messages.nid IS NULL
OR (
na.grant_view >=1
AND (
(
na.gid =0
AND na.realm = 'all'
)
OR (
na.gid =0
AND na.realm = 'og_public'
)
OR (
na.gid =115
AND na.realm = 'og_admin'
)
)
)
)
)
ORDER BY activity_messages_created_minute DESC
LIMIT 0 , 20
Notice that the WHERE clause starts with AND.
I modified line 411 in the latest release of activity.module as follows:
// $return['where'] = " AND ($primary_table.nid IS NULL OR (" . $node_access . "))";
$return['where'] = " ($primary_table.nid IS NULL OR (" . $node_access . "))";
This fixed the error but, honestly, I have no idea what I'm doing so I don't think this is correct fix. Does anyone else understand what's happening here?
Comments
Comment #1
sirkitree commentedHAHA, yup, I just found this myself right before I got your issue in my email :) Fix committed. Thanks!