Add setting to EntityReferenceSelection plugins to prevent references to referencing entity

Created on 5 June 2014, over 10 years ago
Updated 7 February 2023, almost 2 years ago

Problem/Motivation

There should be an option to prevent entity selection plugins from referencing the entity. Where an entity selection plugin is called because it is attached as a field to an entity

Remaining tasks

None

User interface changes

Add checkbox to field configuration

API changes

None

Config/Data model changes

Add configuration for site builders to choose whether to prevent self references.

โœจ Feature request
Status

Needs work

Version

10.1 โœจ

Component
Entityย  โ†’

Last updated about 17 hours ago

  • Maintained by
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom @catch
  • ๐Ÿ‡จ๐Ÿ‡ญSwitzerland @berdir
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany @hchonov
Created by

Live updates comments and jobs are added and updated live.
  • Contributed project blocker

    It denotes an issue that prevents porting of a contributed project to the stable version of Drupal due to missing APIs, regressions, and so on.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

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

  • ๐Ÿ‡ง๐Ÿ‡ทBrazil carolpettirossi Campinas - SP

    This would be really really useful. It's very common to have Content referencing other content of the same type to create blocks like "Related Articles", "Recommended products" and editors being responsible to curate these blocks by choosing the specific nodes in the entity reference field.

    I tested the patch from #79 and it did not work as I show in the video attached:
    Screenshare - 2023-02-07 12_05_04 PM.mp4 (3.96 MB)

  • Status changed to Needs review almost 2 years ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Nitin shrivastava

    For, d10 #79 patch not applied cleanly.
    Fix for d10

  • Status changed to Needs work almost 2 years ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request โ†’ as a guide.

    Issue summary should include the proposed solution to the problem.

    Also since we are adding a new setting this seems like it could affect existing sites. Think we would need an upgrade path.

  • ๐Ÿ‡จ๐Ÿ‡ญSwitzerland berdir Switzerland

    This needs to be redone on top of ๐Ÿ› Entity autocomplete widget does not pass along entity to AJAX request Fixed . That issue already added a test implementation for this, we just need to convert that to a setting like this issue is doing. We can probably remove the test implementation there again.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Liam Morland Ontario, CA ๐Ÿ‡จ๐Ÿ‡ฆ

    Liam Morland โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Liam Morland Ontario, CA ๐Ÿ‡จ๐Ÿ‡ฆ

    I have created a merge request with the patch in #88 ported to 11.x.

    Upgrade path: Perhaps the variable should be prevent_self_reference instead of allow_self_reference. That way, if it is not set, it has the same behaviour as before. Nothing changes until someone configures it differently.

  • Pipeline finished with Success
    9 months ago
    Total: 494s
    #126246
  • Status changed to Needs review 9 months ago
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Liam Morland Ontario, CA ๐Ÿ‡จ๐Ÿ‡ฆ

    The upgrade path already works. I installed this on my 10.2.4 site. In my test field, allow_self_reference was already checked and self-reference was allowed, as before. I unchecked it and self-reference was prevented.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Liam Morland Ontario, CA ๐Ÿ‡จ๐Ÿ‡ฆ
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Liam Morland Ontario, CA ๐Ÿ‡จ๐Ÿ‡ฆ

    Patch from merge request ported to Drupal 10.2.4.

  • Status changed to Needs work 9 months ago
  • The Needs Review Queue Bot โ†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide โ†’ to find step-by-step guides for working with issues.

  • Status changed to Needs review 9 months ago
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Liam Morland Ontario, CA ๐Ÿ‡จ๐Ÿ‡ฆ

    The bot is referring to the patch in 97. The current version is the merge request.

  • Status changed to Needs work 9 months ago
  • The Needs Review Queue Bot โ†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide โ†’ to find step-by-step guides for working with issues.

  • Status changed to Needs review 9 months ago
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Liam Morland Ontario, CA ๐Ÿ‡จ๐Ÿ‡ฆ

    Patch from merge request, just to stop the bot from resetting the status.

  • Status changed to Needs work 9 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    If going to add a new UI setting will probably need usability sign off.

    Also with schema change going to an upgrade path.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Liam Morland Ontario, CA ๐Ÿ‡จ๐Ÿ‡ฆ

    Who does the usability sign-off?

    Does this need an upgrade hook or would it be OK to write it so that if allow_self_reference is not set, is is treated as true to preserve existing behaviour?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Can post in #ux for them to take a look, they also keep an eye on the tag.

    If a configuration file is being updated it will need an upgrade path.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Liam Morland Ontario, CA ๐Ÿ‡จ๐Ÿ‡ฆ

    I rebased the merge request on 11.x. The patch is the current state of the merge request.

  • Pipeline finished with Failed
    15 days ago
    Total: 198s
    #365815
  • Pipeline finished with Success
    15 days ago
    Total: 795s
    #365824
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Liam Morland Ontario, CA ๐Ÿ‡จ๐Ÿ‡ฆ

    Test are now passing.

Production build 0.71.5 2024