I have several views defined with an argument from a cck text field set to "Summary, sorted ascending". There is only one argument defined in the view.
Viewing the view as user 1, the results are properly grouped and the summary count is accurate. Viewing the view as another user results in a summary that contains the same argument repeated multiple times with a smaller count that is a subset of the results.
For example:
As user 1:
Value1 (3)
Value2 (2)
Value3 (5)
As another user:
Value1 (2)
Value2 (2)
Value3 (2)
Value1 (1)
Value3 (3)
If you click on the argument link, then even though it only lists a count of 3 for Value3, say, the resulting page for that argument value does display the correct nodes. So using the example, the Value3 page properly displays 5 nodes for both users.
I suspect that it must be somehow constructing the query with an additional group by or something. After reading through the code, I am at a loss to explain how which user you are could possibly affect that.
I've tested giving the non-user 1 user every permission that I thought might relate (all the views permissions, administer nodes, etc...), but without any effect on the results.
So right now my dozen or so summary views really only work well for user 1, while I'd really like others to be able to enjoy them.
Comments
Comment #1
Thomas Sewell commentedIn case it matters, a sample view definition that exibits the problem:
Comment #2
Thomas Sewell commentedIgnore the warning in the above. Apparently the code filter doesn't like backslashes in that combination of characters.
Comment #3
merlinofchaos commentedSigh. No. Drupal is incorrectly adding a DISTINCT to the query and you're using a node access module of some kind (even if it's not actually active), so the query is being rewritten. This bug drives me crazy.
Comment #4
Thomas Sewell commentedIt appears that the distinct is added by line 2536 of node.module (v 1.641.2.32):
Changing the 1 to a 0 for distinct solves the problem. Obviously this may not be a solution until someone more familiar with the core node module lets us know if there is another way to solve whatever problem they were solving by adding distinct in the first place.
There may be a way to use hook_db_rewrite_sql in the cck module to set distinct=0 under the correct conditions and somehow ensure it's run after node.module's function.
Comment #5
Thomas Sewell commentedRather, I just had the belated realization that while the code listed above sets distinct=1, changing it to 0 may simply be overriding the actual original cause elsewhere in the permissions checking by forcing it to a 0 in a later hook.
Comment #6
merlinofchaos commentedYou are correct. The code that is buggy is the code that is modifying the query to be DISTINCT incorrectly.
Comment #7
Thomas Sewell commentedIs there anything unique about a views node table summary query (since the query is passed into the function) that could be used in a views_db_rewrite_sql function to check for it and set distinct=0 in that case, overriding the node.module's setting distinct=1?
Otherwise, you could set a variable just before calling db_rewrite_sql that could then be referenced by views_db_rewrite_sql to set distinct=0.... I'd have to think about how the variable scope would have to work in that case. I know you're already using a no_distinct reference in various places, but I'm not sure the value is currently referenceable in the scope views_db_rewrite_sql would be in, since I still haven't fully figured out how everything in the views module connects.
Comment #8
Thomas Sewell commentedI tried a few tests creating a views_db_rewrite_sql function to set distinct=0 and couldn't get it to fire and override properly, even though the views weight in the system table is 10.
So I suppose for now I'll disable the cac_lite module so that there aren't any node_access modules in the system to cause the distinct in node.module to fire.
As you say, _sigh_.
Comment #9
yoroy commentedClosing, this version of views is not supported anymore.