It's not working right. I have a view which shows nodes behind nodeaccess for certain roles. I need this view without nodeaccess, to I used your module. As a result, the view results completely disappeared.
Below are my queries, BEFORE and AFTER.
Query BEFORE:
SELECT node.nid AS nid,
node_data_field_photo.field_photo_fid AS node_data_field_photo_field_photo_fid,
node_data_field_photo.field_photo_list AS node_data_field_photo_field_photo_list,
node_data_field_photo.field_photo_data AS node_data_field_photo_field_photo_data,
node.type AS node_type,
node.vid AS node_vid,
node.title AS node_title,
node_data_field_photo.field_location_value AS node_data_field_photo_field_location_value,
node_data_field_photo.field_email_email AS node_data_field_photo_field_email_email,
node_revisions.body AS node_revisions_body,
node_revisions.format AS node_revisions_format
FROM node node
INNER JOIN content_type_people node_data_field_user_type ON node.vid = node_data_field_user_type.vid
LEFT JOIN content_type_people node_data_field_photo ON node.vid = node_data_field_photo.vid
LEFT JOIN node_revisions node_revisions ON node.vid = node_revisions.vid
WHERE (node.status <> 0) AND (node.type in ('people')) AND (node_data_field_user_type.field_user_type_value = 'mt')
ORDER BY node_title ASC
Result: 4 (protected by node access)
Query AFTER:
SELECT node.nid AS nid,
node_data_field_photo.field_photo_fid AS node_data_field_photo_field_photo_fid,
node_data_field_photo.field_photo_list AS node_data_field_photo_field_photo_list,
node_data_field_photo.field_photo_data AS node_data_field_photo_field_photo_data,
node.type AS node_type,
node.vid AS node_vid,
node.title AS node_title,
node_data_field_photo.field_location_value AS node_data_field_photo_field_location_value,
node_data_field_photo.field_email_email AS node_data_field_photo_field_email_email,
node_revisions.body AS node_revisions_body,
node_revisions.format AS node_revisions_format
FROM node node
INNER JOIN content_type_people node_data_field_user_type ON node.vid = node_data_field_user_type.vid
LEFT JOIN content_type_people node_data_field_photo ON node.vid = node_data_field_photo.vid
LEFT JOIN node_revisions node_revisions ON node.vid = node_revisions.vid
WHERE (node.status <> 0) AND (node.type in ('people')) AND (node_data_field_user_type.field_user_type_value = 'mt')
ORDER BY node_title ASC
Result: 0
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | 879148-show-unlimited-results.patch | 1.47 KB | webchick |
| #12 | views_ignore_node_permissions-6.x-1.3.patch | 1.09 KB | dave kopecek |
Comments
Comment #1
Anonymous (not verified) commentedOh I noticed there is no difference in the above queries (strange?) - but still after adding your filter, the view has no more results.
-EDIT-
this is the problem, in views_ignore_node_permissions.module:
$result = db_query_range($query, $args, $offset, $view->pager['items_per_page']);My $view->pager['items_per_page'] is 0 (= "all"). So you need to add a check:
Comment #2
Anonymous (not verified) commentedDespite my above fix, it still does not work.
You also need to set the module weight to > 10+
In system db table, find views_node_etc.. and set weight=10. I set it to 100 to be sure. This needs to go in a .intall file.
Comment #3
crystaldawn commentedThe query change is done in hook views_pre_render() so thats probably why you dont see the query change. It shouldnt need any weight changes since render is the very last function called anyways. It is completely possible that the if statement I have in the pre_render hook isnt firing for your site. I've tried several different methods to detect if the filter is enabled or not but not entirely sure if what I ended with will encompass all scenerios. A quick way to see if this module will even work for you is to comment this line and see if your view starts showing the expected results (which would be nodes that the user doesnt have permissions to see normally).
to
If this doesnt help, then the query that is in the pre-render isnt working for your site for some reason and it would be good to find out why so that it can be modified to encompass your setup as well. If it DOES help, then I would need the $views object for your view so I could see why the if statement isnt functioning properly.
Comment #4
Anonymous (not verified) commentedThe module works for me now, but like I mentioned in #1, you need to check for $view->pager['items_per_page'] = 0 (=all). Also I had to change the module weight, perhaps due to other module conflicts.
But definitely check my patch in #1, it is needed.
Comment #5
nikhil.goyal commentedI have the same problem, the views result completely vanished once I used this module, on my views.
I'm using content access module, to restrict content on per node basis.
If required my the module maintainer I will be glad to show him the site, so he can see the problem.
Edit --
I was able to fix this problem after setting my "Items To Display" to 200 from 0.
Thanks for this module.
Comment #6
crystaldawn commentedThis seems to be a problem when setting 0 as the Limit (items to display). I'll have a look at this thanx.
Comment #7
interestingaftermath commentedI have mine set on limit 5 (with no pager) and I have the same problem. Nothing is showing.
Comment #8
thekevinday commentedI can confirm this problem exists and also confirm that the solution from #1 works.
Edit: might as well do the following:
This code:
$offset = $view->pager['current_page'] * $view->pager['items_per_page'] + $view->pager['offset'];Is only needed with the db_query_range() function, so put this inside of the else brackets.
Comment #9
dkane commentedI too can confirm the problem and the solution in #5 worked for me (setting the number of displayed values to anything other than 0).
I didn't want to go mucking around in the module, but glad that it sounds like a quick fix for the next RC.
Thanks so much for this module and your help with it, it saved me!
Comment #10
thekevinday commented#5 happens to work because db_query() is not being properly called in the original code when needed.
#1 is a proper fix of the issue.
Comment #11
hnln commentedIt didn't work for me because I had a node translation filter and ***CURRENT_LANGUAGE*** didn't get replaced (as it was an arugment).
fix:
below line 18:
add :
(also taken form view.inc)
Comment #12
dave kopecekHad same issue here with offset. Fix in #1 and move of $offset to inside of else as suggested in #8 worked for me.
Patch attached.
Comment #13
gooddesignusa commentedthanks this worked for me on one view. But on another I still get this error:
If the view has results it is fine but if you goto the view before it has any results is when you get the error. To make the view not show anything without submitting I have a global null set in the args. With provide default arg with php code selected using this code:
If I remove the global null from the args it works fine.
Comment #14
webchickI can confirm this bug when you have a view set to 0 (unlimited) results. I can also confirm that this patch works as intended.
The vague title of this issue is leading this to become a dumping ground of every possible problem with this module that people are having. Re-scoping in an effort to stop that. I've also re-rolled the patch to:
a) conform to coding standards
b) use git
c) touch up the comments a bit
I would mark it RTBC, but I'm technically the last person to touch this patch, so I'll leave it "needs review".
Thanks so much for this great module! It's exactly what I needed for my use case: being able to reference organic groups in a node reference field without also making content editors members of all groups.
Comment #15
webchickAnd for folks having this problem who don't know how to apply a patch, a cheap workaround for now is to set your view limit to something like 99999 instead of 0.
Comment #16
dave kopecek#12 >> a) conform to coding standards
Doh! Schooled by webchick on coding standards. Now I'm afraid that Santa knows when I've been bad too.
Comment #17
webchickLOL! :) No offense intended; thanks a lot for the patch!
Comment #18
jwilson3Tested and confirmed the patch in #14 works.