I've noticed today (by coincidence), that here are links to 4 pages at the bottom of my front page for anonymous user, while there are only 2 for admin (that's how it should be!). It is the same for authenticated users (4 pages...), while there are even 6 or 7 for an extra role (authenticated user / employee). For another extra role, there are "only" 4 though... It is quite weird all together!
Clicking to the 3rd page link (as anonymous user), the "Welcome to your new Drupal website!" page is displayed.
I've checked with core Drupal theme (Garland), and it is exactly the same... It is also the same in Firefox 3.5 and in M$IE 8 (I believe it is generated in a wrong way and theme and browser doesn't matter at all....).
Where shall I start resolving this issue? It doesn't look good (professional) at all, so I'd like to resolve it really ASAP.
Comments
Comment #1
luti commentedI've discovered this issue is caused by interaction of node privacy byrole and Taxonomy Access Control modules. If I uninstall either of them, the problem seems to be gone (the problem is I need the functionality of both...).
I've seen exactly the same issue reported among node privacy byrole issues: #282581: Problems with front page node listings, so I think it is a kind of duplicate (altough it seems to work well for me as long as only node privacy byrole module is enabled, but Taxonomy Access Control is not - while in the issue reported that one is not even mentioned...).
And, interestingly, there is something similar also among Taxonomy Access Control issues: #586586: "Welcome to your new Drupal website" is added as last entry to /node homepage .
It seems some extra entries in "node_access" table are causing too many pages to be "calculated" (I have to discover yet how this works, and how could it be resolved...), but in any case, I believe "Welcome to your new Drupal website" shouldn't be displayed even if someone manually "expands" the number of pages (so it is at least in that point Drupal issue, and not some module's issue by my opinion...).
Comment #2
luti commentedI believe I've found it...
The query to get the number of nodes in pager_query() function (includes/pager.inc file) is composed replacing just anything between SELECT and FROM with a simple COUNT(*).
In my case (front page...), "anything" was:
SELECT DISTINCT(n.nid), n.sticky, n.created FROM node n INNER JOIN node_access na ON na.nid = n.nid WHERE ...
(resulting in a list of 18 nodes...)
while replacement created a query:
SELECT COUNT(*) FROM node n INNER JOIN node_access na ON na.nid = n.nid WHERE ...
(and the result was 32...)
No wonder 4 pages were calculated as needed to display all those nodes...
Why 32? Because there were 2 rows with just different realms returned for almost each node, with node_privacy_by_role and term_access...
So, making the number of nodes to be displayed match the list of those nodes (simply count the records returned...) seems to resolve the issue for me. Here is the patch proposed:
As I don't know what are all possible queries passed to this function, I would appreciate any feedback about my patch attached.
Comment #3
luti commentedChanging status...
BTW - Don't know why, but this seems to resolve also the issue of displaying the "Welcome to your new Drupal website" page. If I manually enter URL with the page number higher than the last one available (in example above - where there are 2 pages generated - it would be /node?page=2 or more...), simply the last one actually existing is displayed...
Comment #4
thatoneguy commentedDoes anyone know if this issue exists in Drupal 7? Not that I'm using it, but I will be evaluating it (and the various modules we use) to plan a path for upgrade.
Comment #5
joachim commentedAFAIK, using multiple access module is just asking for trouble.
Also, this is probably not a problem in D7, as queries are build completely differently.
Comment #6
joachim commentedSetting correct status.
Comment #7
danweasel commentedI previously had this issue when using Forum Access/TAC but recently had it recur with only TAC.
There are two things which solved it, which should help someone that wants to track it down.
Forum A
Forum B
Role X
Role Y
Role X is given explicit TAC access to Forum A only; Role Y is given explicit access to all forums.
A user with Role X and Role Y sees correct numbers in Forum B but doubled in Forum A.
Changing the TAC settings to only give Role Y explicit permission for Forum B solves the problem, as does removing Role X from any user with Role Y. In other words, don't set up TAC such that it gives explicit permission to any one user for multiple reasons.
Comment #8
Niklas Fiekas commentedThis can be reproduced up to 8.x. #681760: Try to improve performance and eliminate duplicates caused by node_access table joins has a testcase verifying the problem and an initial patch, that needs to be backported, once it get's in.