Browse Source

forgot about array_key_exists/in_array

Anthony Bretaudeau 6 years ago
parent
commit
4e32e95f6a

+ 2 - 2
tripal_chado/api/modules/tripal_chado.cv.api.inc

@@ -534,7 +534,7 @@ function _chado_update_cvtermpath_root($cv_id, $root_id, $root_name, &$cache,
   }
 
   // If there are no children do nothing.
-  if (!in_array($root_id, $cache['rels'])) {
+  if (!array_key_exists($root_id, $cache['rels'])) {
     return;
   }
 
@@ -611,7 +611,7 @@ function _chado_update_cvtermpath_process_children($cv_id, $root_id, $cvterm_id,
   //print implode('-', $path) . "\n";
 
   // If this term does not have children then return.
-  if (!in_array($cvterm_id, $cache['rels'])) {
+  if (!array_key_exists($cvterm_id, $cache['rels'])) {
     return;
   }
 

+ 2 - 2
tripal_chado/includes/TripalImporter/OBOImporter.inc

@@ -1107,7 +1107,7 @@ class OBOImporter extends TripalImporter {
     $id = $stanza['id'][0];
 
     // First check if we've already used this term.
-    if (in_array($id, $this->used_terms)) {
+    if (array_key_exists($id, $this->used_terms)) {
       return $this->used_terms[$id];
     }
 
@@ -1333,7 +1333,7 @@ class OBOImporter extends TripalImporter {
       // Case 2:  The conflicting term is in the OBO file (ie. has a stanza) and
       // is obsolete and this one is not. Fix it by adding an (obsolete) suffix
       // to the name to avoid the conflict.
-      else if (in_array('is_obsolete', $check_stanza) and ($check_stanza['is_obsolete'][0] == 'true') and in_array('is_obsolete', $stanza) and ($stanza['is_obsolete'][0] != 'true')) {
+      else if (array_key_exists('is_obsolete', $check_stanza) and ($check_stanza['is_obsolete'][0] == 'true') and (!array_key_exists('is_obsolete', $stanza) or ($stanza['is_obsolete'][0] != 'true'))) {
         $new_name = $check_cvterm->getValue('name') . ' (obsolete)';
         $check_cvterm->setValue('name', $new_name);
         $check_cvterm->update();