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"(.*)>( )?<\/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
- Edit any existing field value with media embedded with Entity Embed
<drupal-entity>tags. - 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.
- Save the entity with these changes.
- Install module and run queue to completion
- 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"(.*?)>( )?<\/drupal-entity>/s'
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork convert_entity_media_embed-3460653
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
Comment #3
godotislatePut up an MR with the regexp change that seems to work for our project, in case it's useful to others.
Comment #4
teknocat commentedI 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.
Comment #5
teknocat commented