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:

Enable content moderation.
Grant editor permission to view any unpublished content.
Now the editor can see the reference to the unpublished article:

But when they save, they see the error:

Was able to work around it by setting up an entity reference view.
The issue seems to be in NodeSelection->buildEntityQuery().
Comments
Comment #2
mortona2k commentedComment #4
mortona2k commented