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().
However, when Node ids are collected vua 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 Views view filters out unpublished content also exists - The
\Drupal\node\Plugin\EntityReferenceSelection\NodeSelectionentity reference selection plugin should grant access to (own) unpublished content without additional workarounds, see #2845144: User can't reference unpublished content even when 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