0

My plan is to have a custom page view at blog/% so bloggers can see their own unpublished posts.

If I remove everything except these:

Filter criteria
Content: Type (= Blog entry)
Content: Published (No)

Contextual filters
Content: Author uid

I still can't see the unpublished nodes without making that user an admin. (IE: I log into uid 12 and go to blog/12 - see no nodes. Make uid 12 admin - see 1 unpublished node)

Edit: A look at the SQL shows for admin:

SELECT node.title AS node_title, node.nid AS nid, node.changed AS node_changed, node.created AS node_created
FROM node node
WHERE (( (node.uid = :node_uid ) )AND(( (node.type IN (:db_condition_placeholder_0)) AND (node.status = :db_condition_placeholder_1) ))) 
ORDER BY node_created DESC LIMIT 10 OFFSET 0 

And for normal user:

SELECT node.title AS node_title, node.nid AS nid, node.changed AS node_changed, node.created AS node_created
FROM node node
WHERE (( (node.uid = :node_uid ) )AND(( (node.type IN (:db_condition_placeholder_0)) AND (node.status = :db_condition_placeholder_1) )))
AND ( EXISTS (
  SELECT na.nid AS nid
  FROM node_access na
  WHERE (( (na.gid = :db_condition_placeholder_2) AND (na.realm = :db_condition_placeholder_3) )OR( (na.gid = :db_condition_placeholder_4) AND (na.realm = :db_condition_placeholder_5) )OR( (na.gid = :db_condition_placeholder_6) AND (na.realm = :db_condition_placeholder_7) ))AND (na.grant_view >= :db_condition_placeholder_8) AND (node.nid = na.nid) ))
ORDER BY node_created DESC LIMIT 10 OFFSET 0

Obviously there's a massive amount more SQL for normal users than admins despite my not having put anything related to node_access in there. What is views automatically doing and how can I stop it?

5
  • Have u setup default value as 1 for contextual filter Author uid
    – Cool
    Commented Jan 2, 2014 at 18:34
  • 2
    That sounds like it may be a permissions issue, do the authors have the "View own unpublished content" permission under node? Commented Jan 2, 2014 at 18:45
  • Yes they do. Even if they don't, views usually sidesteps permission issues Commented Jan 2, 2014 at 21:04
  • Really looks like a permission problem...Could you have a look at the content of node_access (for that particular nid) to understand what permission is missing? Commented Jan 3, 2014 at 12:32
  • There are absolutely no rows in node_access corresponding to that nid. Commented Jan 3, 2014 at 12:48

1 Answer 1

2

Since drupal 7.15 drupal injects node_access conditions into queries - these can be disabled with the query tag DANGEROUS_ACCESS_CHECK_OPT_OUT but views' query tag entry doesn't accept uppercase tags (Yay)

The only solution to remove node_access checks is to disable query rewriting entirely in Other > Query Settings

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.