From 3a4129ae831f6b9e4d06c5acb42a14e292578c2d Mon Sep 17 00:00:00 2001
From: Peter Philipp <peter.philipp@cando-image.com>
Date: Mon, 21 Nov 2011 12:17:37 +0100
Subject: [PATCH] Avoid EntityMalformedException - Missing bundle property on
 entity of type...

---
 .../handlers/entity_views_handler_field_field.inc  |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/views/handlers/entity_views_handler_field_field.inc b/views/handlers/entity_views_handler_field_field.inc
index 56af359..5fccb78 100644
--- a/views/handlers/entity_views_handler_field_field.inc
+++ b/views/handlers/entity_views_handler_field_field.inc
@@ -82,13 +82,15 @@ class entity_views_handler_field_field extends views_handler_field_field {
       $entities = array($entities);
     }
     foreach ($entities as $entity) {
-      // Only try to render the field if it is even present on this bundle.
-      // Otherwise, field_view_field() will trigger a fatal.
-      list (, , $bundle) = entity_extract_ids($this->entity_type, $entity);
-      if (field_info_instance($this->entity_type, $this->definition['field_name'], $bundle)) {
-        // Set the currently rendered entity.
-        $values->_field_data[$this->field_alias]['entity'] = $this->entity = $entity;
-        $items = array_merge($items, $this->set_items($values, $this->view->row_index));
+      if (!empty($entity)) {
+        // Only try to render the field if it is even present on this bundle.
+        // Otherwise, field_view_field() will trigger a fatal.
+        list (, , $bundle) = entity_extract_ids($this->entity_type, $entity);
+        if (field_info_instance($this->entity_type, $this->definition['field_name'], $bundle)) {
+          // Set the currently rendered entity.
+          $values->_field_data[$this->field_alias]['entity'] = $this->entity = $entity;
+          $items = array_merge($items, $this->set_items($values, $this->view->row_index));
+        }
       }
     }
     return $items;
-- 
1.7.7.msysgit.1

