Hi!

I have the Recipe module installed for a client project. It's a lovely, well done module. Recently, however, I have started getting the following error:

"Fatal error: Cannot access empty property in /my/directory/sites/name/modules/field/field.attach.inc on line 314"

It's happening *after* the recipe saves. You can edit the recipe again and everything is there but there is NO way to view the recipe. The only modification I've done was to add a Image field to the content type. Which is pretty benign stuff. Even after I remove that field and flush the cache I get the exact same result.

Comments

jvandervort’s picture

Title: Fatal error: Cannot access empty property in /home/group405/sites/orfalea/modules/field/field.attach.inc on line 314 » Fatal error: Cannot access empty property in ../modules/field/field.attach.inc on line 314

Fixed title.

Pimmy’s picture

I get the same error when I try to enable aggregation of more than one content type in Views.
Looking at the code:

foreach ($languages as $langcode) {
  $grouped_items[$field_id][$langcode][$id] = isset($entity->{$field_name}[$langcode]) ? $entity->{$field_name}[$langcode] : array();  // Line 314 causing the error
  // Group the instances and entities corresponding to the current
  // field.
  $grouped_instances[$field_id][$langcode][$id] = $instance;
  $grouped_entities[$field_id][$langcode][$id] = $entities[$id];
}

I see no relation between languages and what triggers the error (agregation in views). Clearing the cache makes no difference. Removing one of the content type from the view, or disabling the aggregation makes the problem disappear - but this is not an option for me.

rantebi’s picture

This error happened when I mistakenly invoked the following method on the wrong node type:
field_view_field('node', $node, 'field_main_image');
The problem was there's no such field in that node type.

dcam’s picture

Issue summary: View changes
Status: Active » Closed (cannot reproduce)

Closing old issues. Sorry you didn't get an answer for this. It's not an excuse, but there wasn't enough information in your report to figure out what was happening. In the future, you should include information like the version of Drupal that you're using. "Line 314" of a file doesn't mean much when that line could change over time. Also, a stack trace from your error logs might have been very useful.