Just had someone do a D6 to D7 migration for us and now we have these notices popping up all over the site.

Notice: Undefined index: und in ctools_entity_from_field_context() (line 173 of C:\xampp\htdocs\sandboxsite2\sites\all\modules\ctools\plugins\relationships\entity_from_field.inc).

Still trying to pinpoint the cause. Couldn't find anyone else reporting this notice so I figured I'd get the ball rolling.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bryancasler’s picture

entity_from_field.inc

165  if (isset($context->data->{$entity_info['entity keys']['id']})) {
166    // Load the entity.
167    $id = $context->data->{$entity_info['entity keys']['id']};
168    $entity = entity_load($from_entity, array($id));
169    $entity = $entity[$id];
170    if (isset($entity->$field_name)) {
171      $language = field_language($from_entity, $entity, $field_name);
172      $to_entity_info_info = entity_get_info($to_entity_info);
173      $to_entity_info_id = $entity->{$field_name}[$language][0][$to_entity_info_info['entity keys']['id']];
174
175      // Send it to ctools.
176      return ctools_context_create('entity:' . $to_entity_info, $to_entity_info_id);
177    }
178  }

I'm not sure if this is related, but after the migration I now have a "Language" column with the value
"Undefined Language ()" appearing on my content page. http://awesomescreenshot.com/00dd9lp99

Could this be related? UPDATE: Fixed this language problem, it is not related.

merlinofchaos’s picture

I suspect we're not completely properly handling field translation correctly, if this is happening. I know it's been an issue in Views, as well. I'm not entirely sure how we're supposed to do this correctly.

merlinofchaos’s picture

For the field in question, is it possible to have no data?

cpelham’s picture

I have just started getting the same error message. My site was built in D7, not upgraded from D6.

My error message is only showing up (so far as I have noticed) on translated content types having a node reference (as well as a date field and a media field). I am just now making these translated nodes, so I suspect it is related to the references module. Just prior to the error message showing up, I applied a new patch to the references module which allows one to translate nodes with references without it throwing (other) errors. What the patch does is look up the child reference and then determine the nid of its translation if one exists and then populate the references field of the newly translated/created parent node with the correct translated child reference. I hope that makes sense.

Animelion, are you using references? I know it's possible it is unrelated or that the same error is being thrown for different reasons...

cpelham’s picture

I don't get that error on every page though so I'll have to look at the fields. Maybe some pages have an empty field that is causing problems? or isn't translated yet?

bryancasler’s picture

The person who did our migration did a botched job. I'm in the process of redoing the migration myself and this error hasn't cropped up yet. @cpelham I don't think I have any reference fields

pontus_nilsson’s picture

Bumped into the same problem, there is another issue, in Panels issue queue #1120022: Node reference field cannot be empty when viewed in node template that describes what I did to run into the problem.

jastraat’s picture

This is also a problem with term reference fields. If you create a relationship in node template to "taxonomy term from node", the term reference field cannot be empty or it errors as above. I also tried to prevent the error by adding a check for whether or not the term field was empty in the selection rules (see http://drupal.org/node/1188466), but even when the selection rules fail, the relationship appears to still execute and error.

Dave Reid’s picture

Status: Active » Needs review
FileSize
1018 bytes

The problem here is the check of if (isset($entity->$field_name)) { when this should be checking !empty() since all fields are defined as an empty array on entity load if they have no value.

merlinofchaos’s picture

Status: Needs review » Fixed

Committed! Thanks!

Status: Fixed » Closed (fixed)

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