Hi,
at least with node_privacy_by_role (but likely also with modules like nodeaccess etc.) the counter at "Export xx results" is wrong and can show a number more than 2 times higher than the real result. That also causes a pager to appear even if there are not enough real results for two pages.
The reason is that with node access modules a node can have many entries in the node_access table, like:
mysql> select * from node_access where nid = 279;
+-----+-----+--------------------------+------------+--------------+--------------+
| nid | gid | realm | grant_view | grant_update | grant_delete |
+-----+-----+--------------------------+------------+--------------+--------------+
| 279 | 1 | node_privacy_byrole_role | 1 | 0 | 0 |
| 279 | 2 | node_privacy_byrole_role | 1 | 0 | 0 |
| 279 | 3 | node_privacy_byrole_role | 1 | 1 | 1 |
| 279 | 3 | node_privacy_byrole_user | 1 | 0 | 0 |
| 279 | 10 | node_privacy_byrole_role | 1 | 0 | 0 |
For a user who is member of roles 2 and 3, the SELECT DISTINCT COUNT(*) FROM {node}... call in biblio_build_query will return "3" because there are three different view grants for nid 279 and roles 2 and 3.
To correct this, I changed the COUNT command to SELECT COUNT(DISTINCT(n.nid)) FROM {node} because we are interested in the number of different nodes, no matter via which role or module we got the access granted. I'm not sure if this patch can cause problems in other situations because I'm not a mysql expert, so please anyone with a node access module test and let me know how it works for you.
cu,
Frank
| Comment | File | Size | Author |
|---|---|---|---|
| biblio_correct_count_with_access_modules.patch | 834 bytes | Frank Steiner |
Comments
Comment #1
catdevrandom commentedI was able to reproduce this bug, but it only happened when I was logged in as a user other than the admin (uid 1).
What I did:
- I installed, in a fresh copy of Drupal, modules tac_light 6.x-1.2, node_privacy_by_role 6.x-1.3 and the biblio that is currently in CVS (biblio.pages.inc,v 1.1.2.24 2008/11/19 14:02:43)
- I set a bunch of overlapping permissions, with two different roles, and assigned them to a regular user. This created a node_access table full of overlapping permissions:
When viewing the list of nodes, the result count was 10, when I had only 2 biblio items available (and the list only showed those 2 nodes).
After Frank's path (I applied the change manually, as the patch was against another version of the file), this issue seems to be fixed.
Comment #2
Frank Steiner commentedNot many people are willing to spend the time for testing patches in this detail! I appreciate your support very much!
Comment #3
catdevrandom commentedNo, thank you for posting the patch in the first place :)
(I guess we all want this to move forward, and the more detailed it is, the easier it gets for Ron to evaluate them and commit them...)
Cheers!
Comment #4
rjerome commentedThanks to both of you...
The patch has been committed to CVS.
Ron.