The following message appears once and a while in the log:
Notice: Undefined index: in languagefield_field_prepare_view() (line 139 of languagefield.module).

Google showed me one other site that shows the message.

CommentFileSizeAuthor
#3 languagefield_2029971_notice.patch675 bytesjohnv
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Alan D.’s picture

Ur... johnv

  $languages = _languagefield_options($field['settings']['enabled'], FALSE, $langcode);

Was this meant to be?

  $languages = _languagefield_options($field['settings']['enabled'], $langcode);

i.e.

function _languagefield_options($subset = LANGUAGEFIELD_LANGUAGES_ALL, $langcode = LANGUAGE_NONE) {
johnv’s picture

You're right. The interface of _languagefield_options() changed on 28-oct-2012 with this commit.

johnv’s picture

Status: Active » Fixed
FileSize
675 bytes

Attached patch is committed here.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

.

ericmulder1980’s picture

I am still seeing this issue for nodes where the languagefield has not been set, i.e. - None - is selected. In my case the nodes are automatically generated with an import script, perhaps that is one of the reasons.

diving into the code i see that $item['value'] is set to FALSE which means it tries to retrieve $languages[FALSE] which does not exist.

Perhaps it is good to check the existence of $item['value]?

  $languages = _languagefield_options($field['settings']['enabled'], $langcode);
  foreach ($entities as $id => $object) {
    foreach ($items[$id] as $delta => $item) {
      // Check if item value is set, otherwise continue to next item.
      if (empty($item['value'])) {
        continue;
      }
      $items[$id][$delta] = $languages[$item['value']];
    }
  }

Above code takes away the notices for me. This means that $items[$id][$delta] would never be set. I am not really sure what the implications for this could be. Perhaps it is better to return LANGUAGE_NONE when $item['value'] is not set to a valid language?

$languages = _languagefield_options($field['settings']['enabled'], $langcode);
  foreach ($entities as $id => $object) {
    foreach ($items[$id] as $delta => $item) {
      // Check if item value is set, otherwise set it to und.
      if (empty($item['value'])) {
        $items[$id][$delta] = LANGUAGE_NONE;
      }
      else {
        $items[$id][$delta] = $languages[$item['value']];
      }
    }
  }
ericmulder1980’s picture

Issue summary: View changes
Status: Closed (fixed) » Active

Re-opened this issue since (in my case) it is still active.

  • johnv committed 4d1f11f on 8.x-1.x
    Issue #2029971: Fixed Notice: Undefined index: in...

  • johnv committed 6fff513 on 7.x-1.x
    Issue #2029971 by ericmulder1980: Fixed Notice: Undefined index: in...

  • johnv committed d6645dd on 8.x-1.x
    Issue #2029971 by ericmulder1980: Fixed Notice: Undefined index: in...
johnv’s picture

Status: Active » Fixed

I prefer to not make assumptions. The default value of the field may be another value. So I committed your first version (slightly changed).
Thanks.

Status: Fixed » Closed (fixed)

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