Grants not created for unpublished nodes

Created on 25 January 2019, over 6 years ago
Updated 28 April 2023, about 2 years ago

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?

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇸🇮Slovenia jzavrl

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024