Browse Source

Merge pull request #1000 from tripal/tv3-cvterm-entities-wont-sync

Cannot Sync cvterm-based entities
Lacey-Anne Sanderson 5 years ago
parent
commit
dec1969181

+ 2 - 2
tripal/includes/tripal.fields.inc

@@ -765,8 +765,8 @@ function tripal_field_widget_form_validate($element, &$form_state, $form) {
   $field = $element['#field'];
   $instance = $element['#instance'];
 
-  $langcode = $element['#language'];
-  $delta = $element['#delta'];
+  $langcode = (isset($element['#language'])) ? $element['#language'] : LANGUAGE_NONE;
+  $delta = (isset($element['#delta'])) ? $element['#delta'] : 0;
 
   $widget_class = $instance['widget']['type'];
   tripal_load_include_field_class($widget_class);

+ 2 - 1
tripal_chado/includes/TripalFields/sio__vocabulary/sio__vocabulary_widget.inc

@@ -27,9 +27,10 @@ class sio__vocabulary_widget extends ChadoFieldWidget {
     // content managers to change it. Thus we need to look up the value for the
     // entity type and use it here.
     if (empty($items)) {
+
       // Use the bundle to get the cv_id choosen for this cvterm-based entity.
       // ASSUMPTION: the cv_id is saved as the "type_value" of the bundle.
-      $bundle = tripal_load_bundle_entity(['name' => $widget['#bundle']]);
+      $bundle = tripal_load_bundle_entity(['name' => $widget['#instance']['bundle']]);
       $cv = chado_get_cv(['cv_id' => $bundle->type_value]);
 
       // Now populate the items array with defaults based on the cv.

+ 7 - 2
tripal_chado/includes/tripal_chado.bundle.inc

@@ -118,6 +118,11 @@ function tripal_chado_create_bundle_table($bundle) {
     throw new Exception('Cannot create entity linker table for chado.');
   }
   db_create_table($chado_entity_table, $schema);
+
+  // Ensure we clear the drupal schema cache after creating this table.
+  // This is needed so we can publish records directly after creating a new
+  // content type.
+  drupal_get_complete_schema(TRUE);
 }
 
 /**
@@ -155,9 +160,9 @@ function tripal_chado_bundle_find_orphans($bundle, $count = FALSE, $offset = 0,
   if (!$count and $limit) {
     $qlimit = "LIMIT $limit OFFSET $offset ";
   }
-  // Get the count 
+  // Get the count
   $query = "
-    SELECT $select  
+    SELECT $select
     FROM [$chado_bundle_table] CT
       LEFT JOIN {" . $bundle->data_table . "} BT ON CT.record_id = BT.$primary_key
     WHERE BT.$primary_key IS NULL