diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index e147c1c..d8f1147 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -1604,7 +1604,11 @@ function taxonomy_field_formatter_view($entity_type, $entity, $field, $instance, ); } else { - $term = $item['taxonomy_term']; + $term = isset($item['taxonomy_term']) ? $item['taxonomy_term'] : taxonomy_term_load($item['tid']); + // Be aware of deleted terms + if (!$term) { + continue; + } $uri = entity_uri('taxonomy_term', $term); $element[$delta] = array( '#type' => 'link', @@ -1618,7 +1622,17 @@ function taxonomy_field_formatter_view($entity_type, $entity, $field, $instance, case 'taxonomy_term_reference_plain': foreach ($items as $delta => $item) { - $name = ($item['tid'] != 'autocreate' ? $item['taxonomy_term']->name : $item['name']); + if ($item['tid'] == 'autocreate') { + $name = $item['name']; + } + else { + $term = isset($item['taxonomy_term']) ? $item['taxonomy_term'] : taxonomy_term_load($item['tid']); + // Be aware of deleted terms + if (!$term) { + continue; + } + $name = $term->name; + } $element[$delta] = array( '#markup' => check_plain($name), ); @@ -1627,9 +1641,20 @@ function taxonomy_field_formatter_view($entity_type, $entity, $field, $instance, case 'taxonomy_term_reference_rss_category': foreach ($items as $delta => $item) { + if ($item['tid'] == 'autocreate') { + $name = $item['name']; + } + else { + $term = isset($item['taxonomy_term']) ? $item['taxonomy_term'] : taxonomy_term_load($item['tid']); + // Be aware of deleted terms + if (!$term) { + continue; + } + $name = $term->name; + } $entity->rss_elements[] = array( 'key' => 'category', - 'value' => $item['tid'] != 'autocreate' ? $item['taxonomy_term']->name : $item['name'], + 'value' => $name, 'attributes' => array( 'domain' => $item['tid'] != 'autocreate' ? url('taxonomy/term/' . $item['tid'], array('absolute' => TRUE)) : '', ),