Embedded entities are not pulled

Created on 17 July 2025, about 2 months ago

Problem/Motivation

Embedded entities are not pulled when data-entity-uuid goes before data-entity-type. There probably exist other scenarios when it is misbehaves.

Steps to reproduce

Create an entity with a formatted text field value like this:

<img src="img.jpg" data-entity-uuid="image-uuid-here" data-entity-type="file">
<drupal-entity data-entity-type="media" data-entity-uuid="media-uuid-here" data-embed-button="media_embed" data-entity-embed-display="view_mode:media.full" data-entity-embed-display-settings="">&nbsp;</drupal-entity>

Note that data-entity-uuid goes before data-entity-type in the <img> tag.

Try to pull that entity and see that image and media are not pulled properly.

Proposed resolution

Update regular expressions to allow any order of the attributes.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡¨πŸ‡ΎCyprus alex.bukach

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

Merge Requests

Comments & Activities

  • Issue created by @alex.bukach
  • πŸ‡¬πŸ‡§United Kingdom joachim

    Thanks for the MR.

    Any chance you could add a test for this?

    There's a new base class for kernel tests that you can use; see the basic kernel test class for an example of how to use it.

  • πŸ‡ΊπŸ‡ΈUnited States pbabin

    We have the same issue as the title; however, I do not believe our issue is related to the patch supplied here. I have tried to apply the patch and it is not working.

    We are experiencing this issue in both D10 and D11 with our shared codebase.

    I've ruled out json_api_extras as a potential issue by turning off this module (we restrict non-related json entities).

    When an image is embedded in the text field of our content such as:

    [Source - entity share server]

    </p>
    <drupal-media data-entity-type="media" data-entity-uuid="7c0a0aec-7d6e-4441-8a87-70d7832d8856">&nbsp;</drupal-media>
    <p>
    

    The content type is brought over with all of the associated fields including the text field this media entity is embedded in. However, on the client we are seeing this:

    [Source - entity share client]

    </p>
    <drupal-media data-entity-type="media" data-entity-uuid="7c0a0aec-7d6e-4441-8a87-70d7832d8856">&nbsp;</drupal-media>
    <p>
    

    However, when rendered we see "The referenced media source is missing and needs to be re-embedded.."

    If I look at the media library the embedded image is not brought over.

    This is the config we have implemented on both the client and the server (single codebase implemented in a production on a custom upstream - but testing locally through a ddev multi-site setup)

    langcode: en
    status: true
    dependencies: {  }
    id: events
    label: Events
    import_maxsize: 50
    import_processor_settings:
      changed_time:
        weights:
          process_entity: 100
      default_data_processor:
        weights:
          is_entity_importable: -10
          post_entity_save: 0
          prepare_importable_entity_data: -50
        policy: default
        update_policy: true
      embedded_entity_importer:
        weights:
          prepare_importable_entity_data: -49
        max_recursion_depth: -1
      entity_reference:
        weights:
          process_entity: 10
        max_recursion_depth: -1
      path_alias_processor:
        weights:
          prepare_importable_entity_data: -48
      physical_file:
        weights:
          process_entity: 0
        rename: false
      skip_imported:
        weights:
          is_entity_importable: -5
    

    If you have any tips or recommendations of what I might be able to adjust or report back to you all, I would greatly appreciate your time and assistance.

  • πŸ‡¬πŸ‡§United Kingdom joachim

    Please please please write tests. Tests will show you clearly what is not working.

Production build 0.71.5 2024