Drupal 7's Access Control module prevents View of user's own unpublished content
I was pulling my hair out about some Drupal 7 Views weirdness! For some reason my normal users weren't able to view their own unpublished content even though they had the permission View own unpublished content permission set under the Node section. Users could view and edit the node if they went to the node directly, but it wasn't possible to show the node in a view, unless the user was an Administrator that is. I had got to the point of installing and using the Views Unpublished module, but this seemed like an imperfect solution.
After a lot of back-tracking and going back to basics, and web searching, I discovered this thread on the Drupal forums http://drupal.org/node/1190096 and that led me to realise that it might be something to do with the Content Access module that I have installed. So I temporarily disabled it and it all started to magically work again: my users could indeed view their own unpublished content.
But I need the Content Access module as I've got role-specific content: for example only users with a given role are allow to see a given news item.
Further reading of the thread made me realise that I could have the best of both worlds: Content Access installed and a View of all a given user's content, unpublished or published.
To do this, one needs to go in to the view in question and choose the Settings for Query settings under the Advanced tab:
And from the next dialogue, tick the Disable SQL rewriting option:
And it works! I'm not sure whether this is a proper solution really: it's kind of more of a hack imho. In my case it's not important for the content type in question that the access control permissions can be disabled, but I guess it may be that someone requires both together; in which case they might find themselves a little bit stuffed.
Perhaps this is a feature that the Content Access module needs to implement, or is it some underlying Drupal design limitation? I don't quite know enough to answer that one at the moment...