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:

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

mxr576 created an issue. See original summary.

mxr576’s picture

Issue summary: View changes
mxr576’s picture

mxr576’s picture

Issue summary: View changes
quietone’s picture

Version: 11.0.x-dev » 11.x-dev
mxr576’s picture

Issue summary: View changes
mxr576’s picture

Title: Grant query level access to own unpublished nodes » Grant query level access to own/any unpublished nodes
Issue summary: View changes
davidwbarratt’s picture

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.

Could you help me replicate this? I'm finding precisely the opposite in #3514221: QueryInterface::accessCheck does not perform access checking in core

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.