Problem/Motivation
When attempting to insert the following code into the WYSIWYG editor
<drupal-media data-entity-type="media" data-entity-uuid="[some-not-existing-id]" data-embed-code-id="original" data-align="center"> </drupal-media>,
an error occurs during node save:
Error: Call to a member function get() on bool in Drupal\acquia_dam_integration_links\AssetDetector\EntityEmbedTextDetector->parseAssetId() (line 124 of modules/contrib/acquia_dam/modules/acquia_dam_integration_links/src/AssetDetector/EntityEmbedTextDetector.php).
This issue arises due to the absence of a check for empty $media before attempting to access its properties.
Steps to reproduce
- Insert the provided
<drupal-media>code into the WYSIWYG editor. - Save the node.
Proposed resolution
To add a check for empty($media) before attempting to access properties in order to prevent the error mentioned above.
Remaining tasks
- Apply the code modification to check for empty($media) before accessing properties.
- Test to ensure the issue is resolved.
- Review and commit the changes.
User interface changes
No user interface changes are expected.
API changes
No API changes are expected.
Data model changes
No data model changes are expected.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 3407783-5-node-save.png | 136.3 KB | baluertl |
| #2 | aquia_dam-3407783-1.patch | 740 bytes | sandzel |
Issue fork acquia_dam-3407783
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 #2
sandzel commentedComment #3
scott_earnest commentedThank you @sandzel for the patch!
This is working for us:
- Drupal 10.1.6
- Acquia DAM Version: 1.0.11
- PHP 8.1.18
RTBC +1
Comment #4
joshf commented@sandzel it looks like you're done working on this? Moving to needs review.
Comment #5
baluertlNow tested, cannot reproduce on the latest development branch

1.1.x. After saving the content entity with the WYSIWYG field it gets properly redirected to its canonical page where the embedded asset is being displayed while the invalid UUID is represented with a generic placeholder reading “The referenced media source is missing and needs to be re-embedded”:This message originates from core's
MediaEmbedfilter plugin which is responsible for processing these<drupal-media …></drupal-media>custom HTML tags you also included as a sample. Interestingly according to Git blame, this entire class hasn't changed for 4 years, so the same protection mechanism should be in place for 10.1.6 which core version @scott_earnest confirmed.Apparently we need a more detailed list of reproduction steps to get closer to the circumstances the reporter had.Half an hour wasted due to a missing step in reproduction steps: the Enhanced integration links sub-module must be enabled.
Comment #7
baluertlDue to the fact that we call
\Drupal\Core\Entity\EntityStorageBase::loadByProperties()which always returns an array both on its positive and negative branches of logic (source code) I see checkingis_array()somewhat pointless. So I support @sandzel's idea to rather checkempty()instead.Comment #10
japerryComment #12
japerryAlso backported to 1.0.x