Problem with "Highest Rated Content" block when Organic Groups is Installed
| Project: | Node Vote |
| Version: | 4.7.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
I noticed that the list of "Highest Rated Content" included different nodes based on whether I was logged in or not.
As I investigated, using the devel.module, I found that the SQL that generates the list for anonomous users was being altered by Organic Groups.
Here's the SQL that's run when a user is authenticated:
SELECT DISTINCT(n.nid), n.title, AVG(vote) AS av_avg
FROM node n, nodevote nv
WHERE n.nid = nv.nid
GROUP BY n.nid
ORDER BY av_avg DESC
LIMIT 0, 5
Here's the SQL that's run when a user is anonomous:
SELECT DISTINCT (n.nid), n.title, AVG(vote) AS av_avg
FROM node n, nodevote nv
INNER JOIN node_access na ON na.nid = n.nid
WHERE (na.grant_view >=1 AND ((na.gid =0 AND na.realm = 'all')
OR (na.gid =0 AND na.realm = 'og_public')
OR (na.gid =0 AND na.realm = 'og_all')))
AND n.nid = nv.nid
GROUP BY n.nid
ORDER BY av_avg DESC
LIMIT 0, 5
Each query reveals a different collection of nodes as "Highest Rated".
