Problem/Motivation
As a content editor who wants to add a node to an EntityQueue, on the /node/[nid]/entityqueue page the buttons for adding to or removing from any queue returns the following notice:
The operation could not be performed for the following reasons:
This entity (taxonomy_term: 57) cannot be referenced.
Adding and removing from the Subqueue page DOES work (/admin/structure/entityqueue/[entityqueue-id]/[generated-entityqueue-subqueue-id])
Steps to reproduce
- Enable Entityqueue and Entityqueue Smartqueue
- Add a new Entityqueue with the type "Smart queue" (/admin/structure/entityqueue)
- Select "Taxonomy term" and Entity type, and select a Taxonomy.
- In the Entity Settings, select a content type
- View content (of the selected type), go the EntityQueue tab, try to add to the generated queue(s)
In my use case, the Taxonomy used is only used for one Content Type, which is also selected in the Entityqueue configuration.
Proposed resolution
??? Is this a problem with the csrf_token? I've been poking/hacking, and it seems removing "_csrf_token:TRUE" from the routing prevents the error, but it doesn't make the buttons on a content's Entityqueue tab work.
Remaining tasks
TBD
User interface changes
TBD
API changes
TBD
Data model changes
TBD
Comments
Comment #2
nels commentedComment #3
sadman commented+1 on having this issue. I don't really have anything to add to the issue description. It perfectly describes the steps to produce the issue. If i create an Entityqueue of type with Smart Queue based on taxonomy term vocabulary. Our editors can not add or remove content items from the node edit page on the Entityqueue tab.
Comment #4
dpiCan confirm with EQ 1.6.
When trying to add a node entity in context to a queue via `/node/{nid}/entityqueue`, wherein the queues are a subqueue(smartqueue).
The subqueues represent taxonomy terms. They are permitted to link to Content (aka node)
The following message is displayed:
I've traced this to what appears to be problems derived from the workaround hooks in
entityqueue_smartqueue_entity_field_storage_infoand/orentityqueue_smartqueue_entity_field_storage_infoWhen the validator attempts to determine the target entity type of the
attached_entityentity reference field grafted onto the\Drupal\entityqueue\Entity\EntitySubqueueentity, it still thinks the target type is entity_subqeueu, not taxonomy_term.Clues
An entity reference handler plugin is created in
ValidReferenceConstraintValidator.phpvia$handler = $this->selectionManager->getSelectionHandler($value->getFieldDefinition(), $entity);. This method gets the target type from the field storage definition, not the field instance. The target type configuration property therefore is pointing to entity_subqueue not taxonomy_term.ValidReferenceConstraintValidator.phpcalls$handler->validateReferenceableEntities($target_ids);Eventually
validateReferenceableEntitiesis called, and the ID validation is performed on the wrong table.Suggested solutions
Either the field storage alters are reworked so it doesnt need to hack in a different entity type in order to work around int/string issues. Perhaps the project should migrate to use https://www.drupal.org/project/dynamic_entity_reference for the field storage to work around int/str in the same column.
Implement and configure a custom EntityReferenceSelection plugin, such that DefaultSelection is not used, which calls out to the undesired table.
Comment #5
dpiGiven above evidence I don't think this is specifically tied to taxonomy (though my example does reference terms)
Comment #6
slydevil commentedI ran into this issue, but my term is unpublished (using Content Moderation) and in my case I cannot add by using the entityqueue page or the tab.
Comment #7
slydevil commentedMaybe related to this ore issue - https://www.drupal.org/project/entityqueue/issues/2383903.
Fixed my issue by creating an entity reference view and swapping the Reference Method of the queue from Default to the view.
Comment #8
dpiYeah, changing the EntityReferenceSelection to use something else is going to allow you to reference more items. But theres a chance you'll be able to reference target entities that it shouldnt be able to. Such as different entity types or bundles.
I see the best way forward as implementing our own EntityReferenceSelection plugin.
Comment #9
uttam commentedYes I was going through the entityqueue module and i feel that it would be nice if there is a option to select the content types for subqueues too.
Comment #10
mlncn commentedGetting the same " This entity (node: 2005) cannot be referenced. " style errors for every unpublished piece of content in the queue.
User 1 does not have this problem. But there are no permissions that could be granted to allow referencing, which makes this a major permissions-related bug.
Comment #11
mlncn commentedThis fixes it for saving the whole entityqueue listing.
Have to admit i'm not sure of other cases.
Comment #12
amateescu commented@mlncn, the problem you're bumping into is a core bug (#2973863: ValidReferenceConstraintValidator should not try to enforce data integrity on pre-existing references), and not related to this issue.