after upgrading from media 2.4 to media 2.6 i now get the following errors when i edit content for every image field within a paragraph:

Notice: Undefined property: ParagraphsItemEntity::$language in media_field_widget_form() (line 143 of /umich4/umich4-test/docroot/sites/default/modules/media/includes/media.fields.inc).
Notice: Undefined property: ParagraphsItemEntity::$language in media_field_widget_form() (line 144 of /umich4/umich4-test/docroot/sites/default/modules/media/includes/media.fields.inc).

i've confirmed this is not an issue in media 2.4.

thanks.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

marthasa created an issue. See original summary.

marthasa’s picture

more information: issue tracks to line 141-144 in media.fields.inc
i don't think nested paragraphs supports hostEntity and we have images within nested paragraphs so there is no $host->language - which is what is throwing the error.

attached are the results of the $element['#entity']->hostEntity() and $element.

i've just added a check for $host->language before using it:
else if ($element['#entity_type'] == 'paragraphs_item' && !empty($form['#entity'])) {
$host = $element['#entity']->hostEntity();
if (isset($host->language)) {
$element['#media_parent_entity_form_langcode'] = $host->language;
$element['#media_parent_entity_source_langcode'] = $host->language;
}
}

but probably needs a default for the else case?

joseph.olstad’s picture

what version of entity_translation are you using?

joseph.olstad’s picture

Status: Active » Needs review
FileSize
790 bytes
marthasa’s picture

not using entity_translation.

thanks for patching!!

  • joseph.olstad authored 0a94b92 on 7.x-3.x
    Issue #2885024 by joseph.olstad, marthasa: Notice: Undefined property:...

  • joseph.olstad authored 0a94b92 on 7.x-2.x
    Issue #2885024 by joseph.olstad, marthasa: Notice: Undefined property:...
joseph.olstad’s picture

Status: Needs review » Fixed

fixed in 7.x-2.x dev and 7.x-3.x dev

awolfey’s picture

It looks to me like this patch and the commit have a typo.

if (isset($host->$language)) {
should be
if (isset($host->language)) {

This is line 11 of the patch in #4.

Thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

joseph.olstad’s picture

it is

$host->language

see ...

includes/media.fields.inc:    if (isset($host->language)) {
//snipped...
includes/media.fields.inc:      $element['#media_parent_entity_form_langcode'] = $host->language;
//snipped...
includes/media.fields.inc:      $element['#media_parent_entity_source_langcode'] = $host->language;