Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Using the media browser with entity embed produces the following error:
Notice: Undefined index: data-entity-embed-display-settings in Drupal\entity_embed\Form\EntityEmbedDialog->validateEmbedStep() (line 578 of entity_embed/src/Form/EntityEmbedDialog.php)
You can see this error and the steps to reproduce here:
https://travis-ci.org/acquia/lightning/jobs/153005688#L1303
Comment | File | Size | Author |
---|---|---|---|
#11 | entity_embed-display-settings-warning-2786493-11.patch | 862 bytes | dagmar |
| |||
#9 | entity_embed-display-settings-warning-2786493-9.patch | 863 bytes | dagmar |
| |||
#7 | entity_embed-display-settings-warning-2786493-7.patch | 807 bytes | dagmar |
|
Comments
Comment #2
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedRecently we changed the name of the attribute: #2760801: Rename data-entity-embed-settings attribute.
I see that Lightning is hard-coding some settings in
lightning_media_form_entity_embed_dialog_alter()
. I suspect that this is where error comes from.Comment #3
phenaproximaI can't reproduce this on Lightning 8.x-1.x, unfortunately...I followed the steps in the failing test exactly, but no dice.
Comment #4
balsamaWe can definitely reproduce this. It looks like a little more than fixing the hard-coded settings, but that's the crux. Thanks slashrsm.
Comment #5
phenaproximaI have traced the problem, and it's not actually Lightning's fault. (I know this partially because I traced it, and partially because I completely disabled the form_alter hook that @slashrsm mentioned and the problem still occurred.)
The problem is that it's very possible for nothing to be present in the attributes section of the Entity Embed dialog form. (In Lightning's case, it's because only one view mode is allowed for the media_browser embed button, so the select list for picking a view mode is never displayed.) The trouble is in EntityEmbedDialog::submitEmbedStep() -- line 735 -- which assumes that
attributes[data-entity-embed-display-settings]
is always present in the form (it uses the ?: operator, which emits an undefined index notice). It needs to do an isset() check or something similar.Comment #6
phenaproximaComment #7
dagmarI saw this error in my logs. This works for me.
Comment #8
Dave ReidI don't think the ?: syntax works with a function call which returns a boolean, because we want to actually return the value.
Comment #9
dagmarOh, right. Here is a new version.
Comment #11
dagmarComment #12
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedLooks good to me.
Comment #14
slashrsm CreditAttribution: slashrsm at MD Systems GmbH commentedCommitted. Thank you all. Assuming Lightning will do its stuff in a separate issue so closing.