When I create content as advanced user, less advanced uses, advanced enough to edit the content, can't edit my content.

Content structure:
- Node type reseller with user reference field_contact
- standard user, status disabled
- standard user, status enabled
- editor user, with edit permissions for reseller nodes
- admin user with user management permissions

Steps to reproduce
- As admin, create a reseller.
- Link both standard users to the new reseller
- As editor user, edit the reseller
- but don't change the node
- hit 'save'

An error occurs: This entity cannot be referenced.
How can it go right the first time? if disabled users are not allowed to be linked, why can I do it as admin, and why can i not edit the content with less permissions?
Please provide consistent behaviour!

Thanks! :-)

CommentFileSizeAuthor
Edit_Reseller.png65.92 KBerlendoos
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

erlendoos created an issue. See original summary.

flyke’s picture

I have the same issue with images.

Multilingual Drupal (8.1.8) site (English as default language, Dutch as second language).
There is a content type 'basic page' that is translatable and has an image field

- As admin, create basic page with image in default language (English)
- As content editor: edit page, do not change anything and click save: no problem
- As content editor: edit page, change language to Dutch via the language selector (NOT using translate tab) and save: no problem
- As content editor: edit page again, do not change anything (language is now Dutch in selector) and save again: Error appears: 'This entity (file: 293) cannot be referenced.'

If you have 5 image fields on the node, then you see this error 5 times (with different fileid).
It is impossible to save the node.
Even changing language back to English does not remove the errors.
As admin: no errors and you can change the language in the selector as much as you want without problem.

I cannot figure out how to resolve these errors, nor how to prevent the language from being changed (I would like to lock the language dropdown so you can see which language you are editing but cannot change it)

erlendoos’s picture

I think this is a different issue. The place where it occurs is at
namespace: Drupal\user\Plugin\EntityReferenceSelection
class: UserSelection
function validateReferenceableNewEntities.

The combination of isActive and 'administer users' not always makes sense, and there is no way to change it's behaviour (that I know of)

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

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

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

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

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

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

tasc’s picture

I assume I got the same problem:
While I'm working on some kind of import I create a number of users and need to reference them in some created nodes.
It works as long as I'm not validating the node-entity prior to saving, otherwise I get "Entity can not be referenced".
Manually adding the (blocked) user to the content when logged in as admin however works.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

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

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

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

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

Kartagis’s picture

I have the same issue with taxonomy term, on products. I have 3 entity reference fields, get the error 3 times with different terms.

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.

jonathanshaw’s picture

Title: Inconsistent behaviour: Entity can not be referenced » Confusion referencing disabled users
Status: Active » Closed (works as designed)

Only users with the 'administer users' permission can reference disabled users. This is by design.

If you desire a different logic, creating a custom entity reference selection handler plugin is extremely easy.