Commit 46284d2e authored by webchick's avatar webchick
Browse files

Issue #1927884 by Alan D., swentel: Always return an array from field_get_items().

parent e8ee8008
......@@ -991,12 +991,12 @@ function field_view_field(EntityInterface $entity, $field_name, $display_options
* Defaults to the current language.
*
* @return
* An array of field items keyed by delta if available, FALSE otherwise.
* An array with available field items keyed by delta.
*/
function field_get_items(EntityInterface $entity, $field_name, $langcode = NULL) {
$entity = $entity->getBCEntity();
$langcode = field_language($entity, $field_name, $langcode);
return isset($entity->{$field_name}[$langcode]) ? $entity->{$field_name}[$langcode] : FALSE;
return isset($entity->{$field_name}[$langcode]) ? $entity->{$field_name}[$langcode] : array();
}
/**
......
......@@ -139,11 +139,8 @@ function get_argument() {
foreach ($fields as $name => $info) {
$field_info = field_info_field($name);
if ($field_info['type'] == 'taxonomy_term_reference') {
$items = field_get_items($node, $name);
if (is_array($items)) {
foreach ($items as $item) {
$taxonomy[$item['tid']] = $field_info['settings']['allowed_values'][0]['vocabulary'];
}
foreach (field_get_items($node, $name) as $item) {
$taxonomy[$item['tid']] = $field_info['settings']['allowed_values'][0]['vocabulary'];
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment