diff --git a/apachesolr_attachments.module b/apachesolr_attachments.module
index 70493ea..2232bde 100644
--- a/apachesolr_attachments.module
+++ b/apachesolr_attachments.module
@@ -469,15 +469,17 @@ function apachesolr_attachments_field_attach_update($parent_entity_type, $parent
         module_load_include('inc', 'apachesolr_attachments', 'apachesolr_attachments.index');
 
         $items = field_get_items($parent_entity_type, $parent_entity, $field_info['field_name']);
-        foreach ($items as $file_info) {
-          $file = file_load($file_info['fid']);
-          // Discard empty entities
-          if (empty($file)) {
-            continue;
+        if ($items) {
+          foreach ($items as $file_info) {
+            $file = file_load($file_info['fid']);
+            // Discard empty entities
+            if (empty($file)) {
+              continue;
+            }
+            // Retrieve parent entity id and add its file usage
+            list($parent_entity_id) = entity_extract_ids($parent_entity_type, $parent_entity);
+            apachesolr_attachments_add_file_usage($file, $parent_entity_type, $parent_entity_id);
           }
-          // Retrieve parent entity id and add its file usage
-          list($parent_entity_id) = entity_extract_ids($parent_entity_type, $parent_entity);
-          apachesolr_attachments_add_file_usage($file, $parent_entity_type, $parent_entity_id);
         }
       }
     }
@@ -499,15 +501,17 @@ function apachesolr_attachments_field_attach_delete($parent_entity_type, $parent
         module_load_include('inc', 'apachesolr_attachments', 'apachesolr_attachments.index');
 
         $items = field_get_items($parent_entity_type, $parent_entity, $field_info['field_name']);
-        foreach ($items as $file_info) {
-          $file = file_load($file_info['fid']);
-          // Discard empty entities
-          if (empty($file)) {
-            continue;
+        if ($items) {
+          foreach ($items as $file_info) {
+            $file = file_load($file_info['fid']);
+            // Discard empty entities
+            if (empty($file)) {
+              continue;
+            }
+            // Retrieve parent entity id and delete its file usage
+            list($parent_entity_id) = entity_extract_ids($parent_entity_type, $parent_entity);
+            apachesolr_attachments_delete_file_usage($file, $parent_entity_type, $parent_entity_id);
           }
-          // Retrieve parent entity id and delete its file usage
-          list($parent_entity_id) = entity_extract_ids($parent_entity_type, $parent_entity);
-          apachesolr_attachments_delete_file_usage($file, $parent_entity_type, $parent_entity_id);
         }
       }
     }
@@ -654,4 +658,4 @@ class ApachesolrAttachmentsEntityFieldQuery extends EntityFieldQuery {
     );
     return $this;
   }
-}
\ No newline at end of file
+}
