Problem/Motivation
Currently "view own unpublished content" access is only checked and grants access a user to its own content when ->access('view') method is called on an already loaded Node object by node id or via loadMultiple().
"view any unpublished content" provided and used by the content_moderation module also implemented with a similar problematic design: #3161658: Content moderation does not implement node grants and thus doesn't integrate its permissions with other grant implementing modules
When Node ids are collected via an entity query or database query with node_access tag in place, unpublished contents by the (current) user are not returned.
E.g.:
$result = \Drupal::entityQuery('node')
->accessCheck(TRUE)
->execute();
This leads to interesting and long term problematic workarounds both in Core and in contrib space:
- IMO the
\Drupal\node\Plugin\views\filter\StatusViews filter should not exist, but it does and therefore #3449181: The Content overview page filters out unpublished nodes when a node access module is enabled also exists - The
\Drupal\node\Plugin\EntityReferenceSelection\NodeSelectionentity reference selection plugin should grant access to (own) unpublished content without additional workarounds, see #2845144: Users without 'bypass node access' permission can't reference unpublished content even if they have access to it - Contrib and custom node access modules should not need to re-implement "view own unpublished content" permission handling in the query access level
Comments
Comment #2
mxr576Comment #3
mxr576Comment #4
mxr576Comment #5
mxr576Comment #6
quietone commentedComment #7
mxr576Comment #8
mxr576Comment #9
davidwbarratt commentedCould you help me replicate this? I'm finding precisely the opposite in #3514221: QueryInterface::accessCheck does not perform access checking in core