Generated with the help of an LLM.

Problem/Motivation

A sub-admin who may edit a blocked user cannot save content that this user authored. The node form fails on the "Authored by" field with:

This entity (user: N) cannot be referenced.

In practice: once the account of a former colleague is blocked, their pages become uneditable for site managers. Plain editors and full administrators are not affected.

Core only accepts a blocked user as a reference for accounts with administer users. For everyone else it ignores an already stored reference to a blocked user, but only if the current user cannot view that user. administerusersbyrole_user_access() grants view on blocked users to anyone who may update them, so for a sub-admin the stored author is no longer ignored and validation fails.

The same happens for other entities with an author field on the form, such as media.

Steps to reproduce

  1. Install Drupal (Standard profile) with Administer Users by Role 8.x-3.6.
  2. Create a role with Edit users with allowed roles, Administer content and Bypass content access control, without Administer users.
  3. Create a user without extra roles and an article authored by that user, then block the user.
  4. Log in as a user with the new role (not uid 1), edit the article and save it unchanged.

Expected: the article is saved.
Actual: "This entity (user: N) cannot be referenced." on the "Authored by" field.

Workaround: choose another author before saving, which loses the original author.

Proposed resolution

To be discussed. The underlying core behaviour is tracked in #2973863: ValidReferenceConstraintValidator should not try to enforce data integrity on pre-existing references, but that issue has been open since 2018 and still needs subsystem maintainer and security review. Sites using this module run into this now, so a fix or workaround in the module seems worthwhile regardless of core.

Remaining tasks

Agree on an approach for this module.

User interface changes

To be determined.

API changes

To be determined.

Data model changes

To be determined.

Comments

srijsbergen created an issue.