I could be wrong and missing an important part of the puzzle, but still.

If you have content_moderation enabled, that means a user can create a node as unpublished and could stay like that for a while. All if working well while the user has the bypass access permission. But when dealing with a non-admin user that can create, edit and delete own nodes and unpublished at that, then the nodes are not showing in views for that user. I've noticed this in the parent issue and posted a quick fix there, but I think this should be fixed here. I don't quite understand the logic behind this and the code was added when the port to D8 was made. Essentially this part of the code is that bugs me:

/**
 * Implements hook_node_access_records().
 */
function content_access_node_access_records(NodeInterface $node) {
  if (content_access_disabling() || !$node->isPublished()) {
    return;
  }

Why is it checking for published here? Wouldn't it make more sense to create the grant regardless of the status?

Comments

jzavrl created an issue. See original summary.

matteferrag’s picture

The code you posted made unpubblished node visible to unlogged users.

gisle’s picture

Version: 8.x-1.x-dev » 2.0.x-dev

This should go into the version compatible with Drupal 10.

steven jones’s picture

Status: Active » Closed (duplicate)
Related issues: +#2993799: Content Authors cannot see unpublished content created by them

Handling this in #2993799: Content Authors cannot see unpublished content created by them so marking this one as a duplicate.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.