Problem/Motivation

Ran into a strange case where a content editor can't edit content that references an unpublished node when content moderation is enabled and they have the view any unbpublished content permission.
On save, it says "This entity (node: 2) cannot be referenced."

Steps to reproduce

Install Drupal 11.4, standard profile.
Create Page and Article content types.
Add an "Articles" reference field.
Create a published article, and an unpublished article.
Create a page that references both.
Create a new content editor user.
Log in as the editor, and edit the page.
Editor sees "-Restricted access-" for the unpublished node, but can save the page:
Edit page as content editor, no content moderation
Enable content moderation.
Grant editor permission to view any unpublished content.
Now the editor can see the reference to the unpublished article:
Edit page as content editor, w/ content moderation and view any unpublished permission
But when they save, they see the error:
Content editor can't save node that references unpublished content

Was able to work around it by setting up an entity reference view.
The issue seems to be in NodeSelection->buildEntityQuery().

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Comments

mortona2k created an issue. See original summary.

mortona2k’s picture

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.