Index: mappers/feedapi_mapper_taxonomy.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/feedapi_mapper/mappers/feedapi_mapper_taxonomy.inc,v
retrieving revision 1.1.4.4
diff -u -p -r1.1.4.4 feedapi_mapper_taxonomy.inc
--- mappers/feedapi_mapper_taxonomy.inc	20 Apr 2009 13:31:04 -0000	1.1.4.4
+++ mappers/feedapi_mapper_taxonomy.inc	9 Jun 2009 08:59:23 -0000
@@ -36,41 +36,31 @@ function taxonomy_feedapi_mapper($op, $n
 }
 
 /**
- * Creates terms from keywords, borrowed from yahoo_terms module.
- * @todo apply http://drupal.org/node/354657#comment-1184004
+ * This helper function creates terms from keywords.
  */
 function _feedapi_mapper_create_terms($keywords, $vid, $static = FALSE) {
-  if ($vid == FALSE) {
-    return FALSE;
-  }
-  $tids = array();
-  if (is_array($keywords)) {
+  $terms = array();
+  if (is_array($keywords) && !empty($vid)) {
     foreach ($keywords as $term) {
       $curr_terms = taxonomy_get_term_by_name($term);
-      if (count($curr_terms) != 0) {
+      $found = FALSE;
+      if (is_array($curr_terms)) {
         foreach ($curr_terms as $curr_term) {
           if ($curr_term->vid == $vid) {
-            $tids[$curr_term->tid] = $curr_term;
+            $terms[$curr_term->tid] = $curr_term;
+            $found = TRUE;
           }
         }
-        if (count($tids) == 0 and $static == FALSE) {
-          $new_term['name'] = $term;
-          $new_term['vid'] = $vid;
-          taxonomy_save_term($new_term);
-          $tids[$new_term['tid']] = taxonomy_get_term($new_term['tid']);
-          unset($new_term);
-        }
       }
-      else {
-        if ($static == FALSE) {
-          $new_term['name'] = $term;
-          $new_term['vid'] = $vid;
-          taxonomy_save_term($new_term);
-          $tids[$new_term['tid']] = taxonomy_get_term($new_term['tid']);
-          unset($new_term);
-        }
+      // Create a new term if there isn't a matching existing one.
+      if (!$found) {
+        $new_term = array();
+        $new_term['name'] = $term;
+        $new_term['vid'] = $vid;
+        taxonomy_save_term($new_term);
+        $terms[$new_term['tid']] = taxonomy_get_term($new_term['tid']);
       }
     }
   }
-  return $tids;
+  return $terms;
 }
