Преглед на файлове

Drupal Search API Tripal Collection bug fix.

Lacey Sanderson преди 6 години
родител
ревизия
34b48a2160
променени са 1 файла, в които са добавени 15 реда и са изтрити 1 реда
  1. 15 1
      tripal/views_handlers/tripal_views_handler_area_collections.inc

+ 15 - 1
tripal/views_handlers/tripal_views_handler_area_collections.inc

@@ -429,7 +429,21 @@ function tripal_views_handler_area_collections_search_api_form_submit($form, $fo
         'fields' => array(),
       );
     }
-    $entities[$bundle]['ids'][] = $r->entity->id;
+    // Note: $r->entity is the entity_id due to the way the search_api saves results.
+    // Doing a check here just in case some search index backends store the data differently.
+    if (is_int($r->entity)) {
+      $entities[$bundle]['ids'][] = $r->entity;
+    }
+    elseif (is_object($r->entity) AND property_exists($r->entity, 'id')) {
+      $entities[$bundle]['ids'][] = $r->entity->id;
+    }
+    else {
+      tripal_report_error(
+        'Tripal Data Collection',
+        TRIPAL_ERROR,
+        'Unable to save entity to collection. Results from the view are: '.print_r($r, TRUE)
+      );
+    }
   }
 
   // Now add the entities to the collection based on bundle.