Browse Source

Fix for issue #727

Stephen Ficklin 6 years ago
parent
commit
fa3ff8dd46

+ 9 - 0
tripal/includes/TripalBundleUIController.inc

@@ -448,6 +448,15 @@ function tripal_tripal_bundle_form_validate($form, $form_state) {
   // PART 2: URL Alias'
   if ($form_state['values']['url']['url_pattern']) {
     $tokens_available = unserialize($form_state['values']['url']['tokens']);
+    
+    // For backwards compatibility we should warn uses if they use the word 
+    // 'feature' as this conflicts with the feature lookup tool. 
+    if (preg_match('/^feature\//', $form_state['values']['url']['url_pattern'])) {
+      $msg = t('The word "feature" should not be used first in the pattern as it conflicts with the feature lookup tool provided by Tripal');
+      form_set_error('url][url_pattern', $msg);
+    }
+    
+    // Now make sure the tokens are valid.
     if (preg_match_all('/(\[\w+\])/', $form_state['values']['url']['url_pattern'], $matches)) {
 
       // The matches of the first and only pattern will be our tokens.

+ 3 - 2
tripal/includes/tripal.bulk_update.inc

@@ -18,11 +18,12 @@ function tripal_update_all_urls_and_titles($bundle_id, $update, $type) {
   $num_entities = $entities->rowCount();
   
   // Parse the $update variable for tokens and load those tokens.
-  preg_match_all("'/\[.*?\]/'", $update, $bundle_tokens);
+  preg_match_all("/\[.*?\]/", $update, $bundle_tokens);
 
   $fields = array();
+  print_r($bundle_tokens);
   foreach ($bundle_tokens as $bundle_token) {
-    $elements = explode(',', $token);
+    $elements = explode(',', $bundle_token[0]);
     $field_name = array_shift($elements);
     $field_array = field_info_field($field_name);
     $fields[] = $field_array['id'];