Browse Source

Fixed bug in core for 7.x

spficklin 11 years ago
parent
commit
7dd85b3ed0

+ 23 - 23
tripal_core/api/tripal_core_chado.api.inc

@@ -1635,6 +1635,9 @@ function tripal_core_expand_chado_vars($object, $type, $to_expand, $table_option
               $object->expanded = $to_expand;
             }
             else {
+              if (!is_object($object->{$foreign_table})) {
+                $object->{$foreign_table} = new stdClass();
+              }
               $object->{$foreign_table} = $foreign_object;
               $object->expanded = $to_expand;
             }
@@ -1642,6 +1645,9 @@ function tripal_core_expand_chado_vars($object, $type, $to_expand, $table_option
           // if the object returned is NULL then handle that
           else {
             if (count($foreign_table_desc['foreign keys'][$base_table]['columns']) > 1) {
+              if (!is_object($object->{$foreign_table})) {
+                $object->{$foreign_table} = new stdClass();
+              }
               $object->{$foreign_table}->{$left} = NULL;
             }
             else {
@@ -2416,27 +2422,21 @@ function chado_table_exists($table) {
  */
 function tripal_core_chado_schema_exists() {
 
-  $exists = variable_get('chado_schema_exists', FALSE);
-
-  if (!$exists) {
-    // This is postgresql-specific code to check the existence of the chado schema
-    // @coder-ignore: acting on pg_catalog schema rather then drupal schema therefore, table prefixing does not apply
-    $sql = "
-      SELECT nspname
-      FROM pg_catalog.pg_namespace
-      WHERE nspname = 'chado'
-    ";
-    $results = db_query($sql);
-    $name = $results->fetchObject();
-    if ($name) {
-      variable_set('chado_schema_exists', TRUE);
-      return TRUE;
-    }
-    else {
-      return FALSE;
-    }
+  // This is postgresql-specific code to check the existence of the chado schema
+  // @coder-ignore: acting on pg_catalog schema rather then drupal schema therefore, table prefixing does not apply
+  $sql = "
+    SELECT nspname
+    FROM pg_catalog.pg_namespace
+    WHERE nspname = 'chado'
+  ";
+  $results = db_query($sql);
+  $name = $results->fetchObject();
+  if ($name) {
+    return TRUE;
+  }
+  else {
+    return FALSE;
   }
-  return TRUE;
 }
 /**
  * Check that any given schema exists
@@ -2604,10 +2604,10 @@ function tripal_core_set_chado_version() {
  */
 function tripal_core_get_chado_version($exact = FALSE, $warn_if_unsupported = FALSE) {
   // first get the chado version that is installed
-  $exact_version = variable_get('chado_version', '');
-  if (!$exact_version) {
+//  $exact_version = variable_get('chado_version', '');
+//  if (!$exact_version) {
     $exact_version = tripal_core_set_chado_version();
-  }
+//  }
 
   // Tripal only supports v1.11 or newer.. really this is the same as v1.1
   // but at the time the v1.11 schema API was written we didn't know that so

+ 2 - 4
tripal_core/includes/chado_install.inc

@@ -362,11 +362,9 @@ function tripal_core_install_sql($sql_file) {
       if (strcmp($type, 'set') == 0 and $chado_local) {
         $query = preg_replace("/public/m", "chado", $query);
       }
-      
-      
-      $previous = tripal_db_set_active('chado');
+
+      // execute the statement
       $result = db_query($query);
-      tripal_db_set_active($previous);
 
       if (!$result) {
         $error  = pg_last_error();

+ 2 - 0
tripal_feature/tripal_feature.module

@@ -1266,6 +1266,8 @@ function tripal_feature_load_featureloc_sequences($feature_id, $featurelocs) {
       // copy over the results to the relationship object.  Since there can
       // be more than one feature location for each relationship feature we
       // use the '$src' variable to keep track of these.
+      $rel->featurelocs = new stdClass();
+      $rel->featurelocs->$src = new stdClass();
       $rel->featurelocs->$src->src_uniquename = $rel_featureloc->src_uniquename;
       $rel->featurelocs->$src->src_cvterm_id  = $rel_featureloc->src_cvterm_id;
       $rel->featurelocs->$src->src_cvname     = $rel_featureloc->src_cvname;