Entity usage should use the processed text value and not the raw text value

Created on 1 April 2025, 1 day ago

Problem/Motivation

Text formats can convert text into links. Entity usage should be calculated from what a user sees not the raw field value.

Steps to reproduce

Add add text into a text field that uses a formatter that automatically converts links to URLs and link is an absolute link to an entity on your site.

Proposed resolution

Use processed text where available.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

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

Merge Requests

Comments & Activities

  • Issue created by @alexpott
  • Pipeline finished with Failed
    1 day ago
    Total: 284s
    #462566
  • Pipeline finished with Failed
    1 day ago
    Total: 237s
    #462579
  • Pipeline finished with Failed
    1 day ago
    Total: 238s
    #462595
  • Pipeline finished with Failed
    about 11 hours ago
    Total: 454s
    #463255
  • Pipeline finished with Success
    about 11 hours ago
    Total: 886s
    #463262
  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    Now to add test coverage...

  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    I've been thinking about this issue and it makes me wonder if we should be maintaining:

    • \Drupal\entity_usage\Plugin\EntityUsage\Track\EntityEmbed
    • \Drupal\entity_usage\Plugin\EntityUsage\Track\HtmlLink
    • \Drupal\entity_usage\Plugin\EntityUsage\Track\MediaEmbed
    • \Drupal\entity_usage\Plugin\EntityUsage\Track\LinkIt
    • \Drupal\entity_usage\Plugin\EntityUsage\Track\CkeditorImage

    I think we should have a single text field plugin that uses the processed text (and summary if available) to determine usage. The plugin should support entity usage discovery from both the URL and the data-entity-uuid and data-entity-type attributes.

    This approach would have the following advantages:

    • No double reporting from LinkIt/ EntityEmbed / CkEditorImage / MediaEmbed - these plugins are all essentially the same - they use the attributes to determine if there is a link
    • A single plugin working through all the links is more performant and less code to maintain
    • Support for any esoteric filter that adds links in a way not covered by the existing plugins
  • Pipeline finished with Success
    about 9 hours ago
    Total: 276s
    #463372
  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

    @marcosano has pointed out that entity embed is a problem. Entity embed possibly will add links to other entities and we wouldn't want these usages registered as part of the entity with text field... so yeah #4 is wrong-headed.

    That said I think it points to the fact that we could reorganise the plugin relationships so we only have to create the dom for each text field once.

  • Pipeline finished with Failed
    about 8 hours ago
    Total: 235s
    #463405
  • Pipeline finished with Failed
    about 8 hours ago
    Total: 245s
    #463409
  • Pipeline finished with Success
    about 8 hours ago
    Total: 234s
    #463411
  • πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ
Production build 0.71.5 2024