Browse Source

Fix to Chado API for major Drupal upgrades

Stephen Ficklin 9 years ago
parent
commit
7d7e8fcf97

+ 26 - 6
tripal/tripal.module

@@ -4,12 +4,8 @@
  * The Tripal Core module
  */
 
-require_once "api/tripal.notice.api.inc";
-require_once "api/tripal.entities.api.inc";
-require_once "api/tripal.files.api.inc";
-require_once "api/tripal.jobs.api.inc";
-require_once "api/tripal.notice.api.inc";
-require_once "api/tripal.variables.api.inc";
+// Import the full Tripal API into scope.
+tripal_import_api();
 
 require_once "includes/TripalVocab.inc";
 require_once "includes/TripalVocabController.inc";
@@ -776,4 +772,28 @@ function tripal_menu_alter(&$items) {
 function tripal_field_no_delete() {
   drupal_set_message('This field is currently managed by the biological data store and cannot be removed.', 'warning');
   return '';
+}
+
+/**
+ * Imports all of the Tripal API into scope.
+ *
+ * Typically this function call is not necessary as all of the API is
+ * automaticaly included by the tripal module.  However this function can
+ * be useful in the .install files during a site upgrade when the tripal
+ * module is not enabld.
+ *
+ * Example usage:
+ * @code
+ *   module_load_include('module', 'tripal', 'tripal');
+ *   tripal_import_api();
+ * @endcode
+ *
+ */
+function tripal_import_api() {
+  module_load_include('inc', 'tripal', 'api/tripal.d3js.api');
+  module_load_include('inc', 'tripal', 'api/tripal.entities.api');
+  module_load_include('inc', 'tripal', 'api/tripal.files.api');
+  module_load_include('inc', 'tripal', 'api/tripal.jobs.api');
+  module_load_include('inc', 'tripal', 'api/tripal.notice.api');
+  module_load_include('inc', 'tripal', 'api/tripal.variables.api');
 }

+ 13 - 1
tripal_chado/api/tripal_chado.schema.api.inc

@@ -367,7 +367,19 @@ function chado_get_schema($table) {
 
   // get the table array from the proper chado schema
   $v = preg_replace("/\./", "_", $v); // reformat version for hook name
-  $table_arr = module_invoke_all("chado_schema_v" . $v . "_" . $table);
+
+  // Call the module_invoke_all.
+  $hook_name = "chado_schema_v" . $v . "_" . $table;
+  $table_arr = module_invoke_all($hook_name);
+
+  // If the module_invoke_all returned nothing then let's make sure there isn't
+  // An API call we can call directly.  The only time this occurs is
+  // during an upgrade of a major Drupal version and tripal_core is disabled.
+  if ((!$table_arr or !is_array($table_arr)) and
+        function_exists('tripal_core_' . $hook_name)) {
+    $api_hook = "tripal_core_" . $hook_name;
+    $table_arr = $api_hook();
+  }
 
   // if the table_arr is empty then maybe this is a custom table
   if (!is_array($table_arr) or count($table_arr) == 0) {

+ 28 - 1
tripal_panes/tripal_panes.install

@@ -104,7 +104,7 @@ function tripal_panes_schema() {
     ),
     'primary key' => array('pane_field_id'),
   );
-  
+
   return $schema;
 }
 
@@ -155,4 +155,31 @@ function tripal_add_tripal_bundle_panes_table(){
     ),
   );
   chado_create_custom_table('tripal_bundle_panes', $schema, TRUE);
+}
+
+function tripal_panes_update_7203() {
+  module_load_include('module', 'tripal_ws', 'tripal_ws');
+
+  tripal_ws_test();
+}
+
+
+/**
+ * Implementation of hook_update_dependencies().
+ *
+ * It specifies a list of other modules whose updates must be run prior to
+ * this one.  It also ensures the the Tripal API is in scope for site
+ * upgrades when tripal is disabled.
+ */
+function tripal_panes_update_dependencies() {
+  // Make sure we have the full API loaded this will help during a
+  // site upgrade when the tripal_core module is disabled.
+  //module_load_include('module', 'tripal', 'tripal');
+  //tripal_import_api();
+print "HI!!!\n";
+  module_load_include('module', 'tripal_ws', 'tripal_ws');
+
+  $dependencies = array();
+
+  return $dependencies;
 }

+ 4 - 0
tripal_ws/tripal_ws.module

@@ -38,4 +38,8 @@ function tripal_ws_menu() {
   );
 
   return $items;
+}
+
+function tripal_ws_test() {
+  print "Blah!!!!\n";
 }