Problem/Motivation

After test running the convert_entity_media_embed_entities queue dev environment content, a database search revealed one field value with a <drupal-entity> tag that was not converted to media. Investigation revealed that the value in question had a new line "\n" character within the tag markup. New lines are not matched by the /<drupal-entity(.*)data-entity-type="media"(.*)>(&nbsp;)?<\/drupal-entity>/ regular expression pattern.

Not sure whether having a new line in this markup is an edge case or unexpected user input at some point.

Steps to reproduce

  1. Edit any existing field value with media embedded with Entity Embed <drupal-entity> tags.
  2. Add a new line anywhere inside the open tag either between 'drupal-entity' and 'data-entity-type="media"', or 'data-entity-type="media"' and '>' of the open tag.
  3. Save the entity with these changes.
  4. Install module and run queue to completion
  5. Confirm that the changed field value was not converted to drupal media tags

Proposed resolution

Change the pattern to include 's', so that '.' matches new lines. In doing this, the pattern also needs to be changed to not be greedy: '/<drupal-entity(.*?)data-entity-type="media"(.*?)>(&nbsp;)?<\/drupal-entity>/s'

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

godotislate created an issue. See original summary.

godotislate’s picture

Status: Active » Needs review

Put up an MR with the regexp change that seems to work for our project, in case it's useful to others.

teknocat’s picture

I just realised that this will also effectively fix https://www.drupal.org/project/convert_entity_media_embed/issues/3491721, because it makes the regex non-greedy as well. Should have reviewed this one before creating my merge request for that one.

The other issue should probably be marked as a duplicate and closed in favour of this one.

teknocat’s picture