Problem/Motivation

BlockContent entities are now publishable (https://www.drupal.org/project/drupal/issues/2820848) but the permission used to allow viewing unpublished blocks is the administer block content or access block library permissions.

When used with Content Moderation, block_content entities can be created as inline (for use in Layout builder) or reusable (via the block content library) as unpublished (this will be expanded without CM in #2834546: UI for publishing/unpublishing block_content blocks). If a user creates a Draft block, any editors without the administer block content or access block library permissions will be unable to view the block that is placed via a block plugin or inline block in Layout builder.

e.g an editor that doesn't have those permissions but has create and edit custom blocks will be able to place reusable blocks in LB but won't be able to view them if they are draft.

Node has a similar permission to view (own) unpublished content

Steps to reproduce

Create unpublished block
Unable to view unless the user has administer block content or access block library permissions

The user must also not have the view any unpublished content permission from CM as that allows viewing any unpublished entity.
There is also a strange side effect that on the Layout page, the user will be able to see it because in BlockComponentRenderArray::onBuildRender block access isn't checked when in preview (i.e on the Layout page) but they won't see it when viewing the node.

Proposed resolution

Add a view unpublished block content permission

Remaining tasks

Release notes snippet

A new "view unpublished block content" permission allows editors to view unpublished blocks. The "administer block content" or "access block library" permissions may no longer be needed for certain editor roles.

Issue fork drupal-3020938

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

JurgenR created an issue. See original summary.

jurgenr’s picture

StatusFileSize
new1.27 KB

I've added a patch which adds a 'View unpublished blocks' permission.

cilefen’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: 3020938-2.patch, failed testing. View results

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

acbramley made their first commit to this issue’s fork.

acbramley’s picture

Title: Add view unpublished blocks permission » Add view unpublished block content permission
Issue summary: View changes

acbramley’s picture

Status: Needs work » Needs review

While not super useful now, I think this will be quite desirable once #2834546: UI for publishing/unpublishing block_content blocks is in.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs change record

Can we get a CR for the new permission?

acbramley’s picture

Status: Needs work » Needs review
Issue tags: -Needs change record

Done https://www.drupal.org/node/3533073

I wasn't really sure if a small FR like this warranted a CR.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Tested this one by added the permission to the editor role in the standard profile.
Created an unpublished blocked
Logged in as that user
Verified I could see the block even though did not have access block library

Seems like a nice addition, and know a few clients that have wanted this and ability to preview the block (separate ticket).

LGTM

catch’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs product manager review

Tagging this one for product manager review.

Also where can you actually see the unpublished block? In the site layout itself or are there other places where it becomes accessible (that don't require the admin permissions anyway)?

acbramley’s picture

Also where can you actually see the unpublished block?

When it's placed via a block plugin

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

This one has been sitting around for almost 4 months. Think it's still worth doing but I'm not a product manager. Maybe core committer could get them to look?

quietone’s picture

Status: Reviewed & tested by the community » Needs review

This issue was tagged by a core committer for product manager review, so I don't really understand comment #21.

Setting back to NR for product manager review.

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.

pameeela’s picture

Not sure this makes sense to commit before #2834546: UI for publishing/unpublishing block_content blocks?

acbramley’s picture

You can have unpublished block content without that issue via content moderation, also that issue is a bit of a mess (see https://www.drupal.org/project/drupal/issues/2834546#comment-16087649)

smustgrave’s picture

For what its worth still a +1 for this and hope we can unblock it before D12

pameeela’s picture

Tested with content moderation based on @acbramley's comment, indeed it already is supported, so I agree this permission is useful.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

I'm not a product manager but seems this has got a number of +1, maybe a core committer could have better luck getting sign off?

gábor hojtsy’s picture

The issue summary does not explain (a) how does this compare to other content entity permissions in core (b) how do we envision it being used. Is this a "basic content staging" kind of thing? What kind of user role / persona would get this permission and how would they use it?

smustgrave’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs issue summary update

Thank you @gabor so much for taking a look. Moving to NW to give it a summary update!

acbramley’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs issue summary update

We are just expanding what is possible with existing permissions, but I've added some rationale to the IS.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for taking care of this acbramley been a hectic day

acbramley’s picture

Issue summary: View changes

Tested this out more thoroughly and added some more caveats.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new1.26 KB

The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

smustgrave’s picture

Status: Needs work » Reviewed & tested by the community

There was a valid PHPCS added so that's been addressed.

larowlan’s picture

xjm asked me to review this - it looks good to me - it has all the sign offs - product manager, product manager of Drupal CMS, both Subsystem maintainers

smustgrave’s picture

So this one can finally be merged :)

xjm’s picture

Issue tags: +DrupalSouth 2026

Technically, this is still tagged with "Needs project manager review", and Gábor had raised reservations without officially signing off on the responses to them. I'll reach out to the project managers.

gábor hojtsy’s picture

Thanks for expanding the rationale in the issue summary. I think this makes sense now. Removing tag as a Drupal core product manager.

  • longwave committed 3c62e4ff on 11.4.x
    feat: #3020938 Add view unpublished block content permission
    
    By:...

  • longwave committed d66ddf6c on 11.x
    feat: #3020938 Add view unpublished block content permission
    
    By:...

  • longwave committed 75becbf6 on main
    feat: #3020938 Add view unpublished block content permission
    
    By:...
longwave’s picture

Version: main » 11.4.x-dev
Issue summary: View changes
Status: Reviewed & tested by the community » Fixed
Issue tags: +11.4.0 release notes

I think we can still sneak this into 11.4.

Committed and pushed 75becbf693d to main and d66ddf6ca3f to 11.x and 3c62e4ff5e5 to 11.4.x. Thanks!

Tagging for release notes, also updated and published the CR.

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.

longwave’s picture

Issue summary: View changes

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.