Entity subqueue tab: The entity cannot be referenced

Created on 3 June 2021, over 3 years ago
Updated 28 September 2023, about 1 year ago

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

πŸ› Bug report
Status

Active

Version

1.0

Component

Documentation

Created by

πŸ‡ΊπŸ‡ΈUnited States Nels

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¦πŸ‡ΊAustralia dpi Perth, Australia

    Can 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:

    The operation could not be performed for the following reasons:
    This entity (taxonomy_term: 123456) cannot be referenced.

    I've traced this to what appears to be problems derived from the workaround hooks in entityqueue_smartqueue_entity_field_storage_info and/or entityqueue_smartqueue_entity_field_storage_info

    When the validator attempts to determine the target entity type of the attached_entity</cod> entity reference field grafted onto the <code>\Drupal\entityqueue\Entity\EntitySubqueue entity, it still thinks the target type is entity_subqeueu, not taxonomy_term.

    Clues

    An entity reference handler plugin is created in ValidReferenceConstraintValidator.php via $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.php calls $handler->validateReferenceableEntities($target_ids);

    Eventually validateReferenceableEntities is 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.

  • πŸ‡¦πŸ‡ΊAustralia dpi Perth, Australia

    Given above evidence I don't think this is specifically tied to taxonomy (though my example does reference terms)

  • πŸ‡¨πŸ‡¦Canada slydevil Halifax

    I ran into this issue, but my term is unpublished (using Content Moderation).

  • πŸ‡¨πŸ‡¦Canada slydevil Halifax

    Maybe 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.

  • πŸ‡¦πŸ‡ΊAustralia dpi Perth, Australia

    Yeah, 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.

  • Yes 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.

Production build 0.71.5 2024