Browse Source

Applied patches by Nathan Weeks: Issue #2367053

Stephen Ficklin 10 years ago
parent
commit
5149855b45

+ 18 - 8
tripal_core/api/tripal_core.chado_nodes.title_and_path.inc

@@ -418,13 +418,14 @@ function chado_add_admin_form_set_title_form_submit($form, $form_state) {
  *   of the specified content type.
  */
 function chado_node_get_title_format($content_type, &$tokens, $base_table = NULL) {
-  $format = '';
+  $format_record_format = $format = '';
+  $format_record_tokens = '';
 
   // Is there a title format set?
   $format_record = chado_node_get_token_format('title', $content_type, array('return_record' => TRUE));
   if (!empty($format_record)) {
-    $format = $format_record->format;
-    $tokens = $format_record->tokens;
+    $format_record_format = $format = $format_record->format;
+    $format_record_tokens = $tokens = $format_record->tokens;
   }
 
   // All three options below need the tokens to be generated so do that now
@@ -457,7 +458,11 @@ function chado_node_get_title_format($content_type, &$tokens, $base_table = NULL
   }
 
   // Add the format to table so we can use it later
-  chado_node_add_token_format('title', $content_type, $format, $tokens);
+  // (optimization: to speed up bulk updates, don't update the record if
+  // the format and tokens are unchanged)
+  if ($format != $format_record_format || $tokens != $format_record_tokens) {
+    chado_node_add_token_format('title', $content_type, $format, $tokens);
+  }
 
   return $format;
 }
@@ -947,13 +952,14 @@ function chado_add_admin_form_set_url_form_submit($form, $form_state) {
  *   of the specified content type.
  */
 function chado_node_get_url_format($content_type, &$tokens, $base_table = NULL) {
-  $format = '';
+  $format_record_format = $format = '';
+  $format_record_tokens = '';
 
   // Is there a url format set?
   $format_record = chado_node_get_token_format('url', $content_type, array('return_record' => TRUE));
   if (!empty($format_record)) {
-    $format = $format_record->format;
-    $tokens = $format_record->tokens;
+    $format_record_format = $format = $format_record->format;
+    $format_record_tokens = $tokens = $format_record->tokens;
   }
 
   // All three options below need the tokens to be generated so do that now
@@ -988,7 +994,11 @@ function chado_node_get_url_format($content_type, &$tokens, $base_table = NULL)
   }
 
   // Add the format to table so we can use it later
-  chado_node_add_token_format('url', $content_type, $format, $tokens);
+  // (optimization: to speed up bulk updates, don't update the record if
+  // the format and tokens are unchanged)
+  if ($format != $format_record_format || $tokens != $format_record_tokens) {
+    chado_node_add_token_format('url', $content_type, $format, $tokens);
+  }
 
   return $format;
 }

+ 0 - 4
tripal_core/tripal_core.install

@@ -380,10 +380,6 @@ function tripal_core_tripal_token_schema() {
         'not null' => TRUE
       ),
     ),
-    'indexes' => array(
-      'tripal_format_id' => array('tripal_format_id'),
-      'type_application' => array('content_type', 'application'),
-    ),
     'unique keys' => array(
       'type_application' => array('content_type', 'application'),
     ),