|  | @@ -633,9 +633,9 @@ class TripalEntityController extends EntityAPIController {
 | 
											
												
													
														|  |          $function = 'field_attach_load';
 |  |          $function = 'field_attach_load';
 | 
											
												
													
														|  |        }
 |  |        }
 | 
											
												
													
														|  |        foreach ($queried_entities as $id => $entity) {
 |  |        foreach ($queried_entities as $id => $entity) {
 | 
											
												
													
														|  | -        $info = entity_get_info($entity->type);
 |  | 
 | 
											
												
													
														|  | 
 |  | +        $info = entity_get_info($queried_entities[$id]->type);
 | 
											
												
													
														|  |          $field_cache = array_key_exists('field cache', $info) ? $info['field cache'] : FALSE;
 |  |          $field_cache = array_key_exists('field cache', $info) ? $info['field cache'] : FALSE;
 | 
											
												
													
														|  | -        $bundle_name = $entity->bundle;
 |  | 
 | 
											
												
													
														|  | 
 |  | +        $bundle_name = $queried_entities[$id]->bundle;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          // Iterate through the field instances and find those that are set to
 |  |          // Iterate through the field instances and find those that are set to
 | 
											
												
													
														|  |          // 'auto_attach' and which are attached to this bundle. Add all
 |  |          // 'auto_attach' and which are attached to this bundle. Add all
 | 
											
										
											
												
													
														|  | @@ -647,8 +647,8 @@ class TripalEntityController extends EntityAPIController {
 | 
											
												
													
														|  |            $field_id = $field['id'];
 |  |            $field_id = $field['id'];
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |            // Add this field to the entity with default value.
 |  |            // Add this field to the entity with default value.
 | 
											
												
													
														|  | -          if (!isset($queried_entities[$id]->$field_name)) {
 |  | 
 | 
											
												
													
														|  | -            $queried_entities[$id]->$field_name = array();
 |  | 
 | 
											
												
													
														|  | 
 |  | +          if (!isset($queried_entities[$id]->{$field_name})) {
 | 
											
												
													
														|  | 
 |  | +            $queried_entities[$id]->{$field_name} = array();
 | 
											
												
													
														|  |            }
 |  |            }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |            // Options used for the field_attach_load function.
 |  |            // Options used for the field_attach_load function.
 | 
											
										
											
												
													
														|  | @@ -663,7 +663,7 @@ class TripalEntityController extends EntityAPIController {
 | 
											
												
													
														|  |            if ($field_cache) {
 |  |            if ($field_cache) {
 | 
											
												
													
														|  |              $cache_data = cache_get($cfid, 'cache_field');
 |  |              $cache_data = cache_get($cfid, 'cache_field');
 | 
											
												
													
														|  |              if (!empty($cache_data)) {
 |  |              if (!empty($cache_data)) {
 | 
											
												
													
														|  | -              $queried_entities[$id]->$field_name = $cache_data->data;
 |  | 
 | 
											
												
													
														|  | 
 |  | +              $queried_entities[$id]->{$field_name} = $cache_data->data;
 | 
											
												
													
														|  |                $queried_entities[$id]->{$field_name}['#processed'] = TRUE;
 |  |                $queried_entities[$id]->{$field_name}['#processed'] = TRUE;
 | 
											
												
													
														|  |                continue;
 |  |                continue;
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
										
											
												
													
														|  | @@ -673,11 +673,11 @@ class TripalEntityController extends EntityAPIController {
 | 
											
												
													
														|  |            // to only load the  fields specified.
 |  |            // to only load the  fields specified.
 | 
											
												
													
														|  |            if (count($field_ids) > 0) {
 |  |            if (count($field_ids) > 0) {
 | 
											
												
													
														|  |              if (in_array($field_id, $field_ids)) {
 |  |              if (in_array($field_id, $field_ids)) {
 | 
											
												
													
														|  | -              $function($this->entityType, array($entity->id => $queried_entities[$id]),
 |  | 
 | 
											
												
													
														|  | 
 |  | +              $function($this->entityType, array($id => $queried_entities[$id]),
 | 
											
												
													
														|  |                    FIELD_LOAD_CURRENT, $options);
 |  |                    FIELD_LOAD_CURRENT, $options);
 | 
											
												
													
														|  |                // Cache the field.
 |  |                // Cache the field.
 | 
											
												
													
														|  |                if ($field_cache) {
 |  |                if ($field_cache) {
 | 
											
												
													
														|  | -                cache_set($cfid, $entity->$field_name, 'cache_field');
 |  | 
 | 
											
												
													
														|  | 
 |  | +                cache_set($cfid, $queried_entities[$id]->{$field_name}, 'cache_field');
 | 
											
												
													
														|  |                }
 |  |                }
 | 
											
												
													
														|  |                $queried_entities[$id]->{$field_name}['#processed'] = TRUE;
 |  |                $queried_entities[$id]->{$field_name}['#processed'] = TRUE;
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
										
											
												
													
														|  | @@ -698,16 +698,16 @@ class TripalEntityController extends EntityAPIController {
 | 
											
												
													
														|  |                 // Add an empty value. This will allow the tripal_entity_view()
 |  |                 // Add an empty value. This will allow the tripal_entity_view()
 | 
											
												
													
														|  |                 // hook to add the necessary prefixes to the field for ajax
 |  |                 // hook to add the necessary prefixes to the field for ajax
 | 
											
												
													
														|  |                 // loading.
 |  |                 // loading.
 | 
											
												
													
														|  | -               $queried_entities[$id]->$field_name['und'][0]['value'] = '';
 |  | 
 | 
											
												
													
														|  | 
 |  | +               $queried_entities[$id]->{$field_name}['und'][0]['value'] = '';
 | 
											
												
													
														|  |                 $queried_entities[$id]->{$field_name}['#processed'] = FALSE;
 |  |                 $queried_entities[$id]->{$field_name}['#processed'] = FALSE;
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |              else {
 |  |              else {
 | 
											
												
													
														|  | -              $function($this->entityType, array($entity->id => $queried_entities[$id]),
 |  | 
 | 
											
												
													
														|  | 
 |  | +              $function($this->entityType, array($id => $queried_entities[$id]),
 | 
											
												
													
														|  |                    FIELD_LOAD_CURRENT, $options);
 |  |                    FIELD_LOAD_CURRENT, $options);
 | 
											
												
													
														|  |                // Cache the field.
 |  |                // Cache the field.
 | 
											
												
													
														|  |                if ($field_cache) {
 |  |                if ($field_cache) {
 | 
											
												
													
														|  | -                if (property_exists($entity, $field_name)) {
 |  | 
 | 
											
												
													
														|  | -                  cache_set($cfid, $entity->$field_name, 'cache_field');
 |  | 
 | 
											
												
													
														|  | 
 |  | +                if (property_exists($queried_entities[$id], $field_name)) {
 | 
											
												
													
														|  | 
 |  | +                  cache_set($cfid, $queried_entities[$id]->{$field_name}, 'cache_field');
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
												
													
														|  |                }
 |  |                }
 | 
											
												
													
														|  |                $queried_entities[$id]->{$field_name}['#processed'] = TRUE;
 |  |                $queried_entities[$id]->{$field_name}['#processed'] = TRUE;
 |