diff -u b/plugins/existing_terms.inc b/plugins/existing_terms.inc --- b/plugins/existing_terms.inc +++ b/plugins/existing_terms.inc @@ -84,7 +33,7 @@ function feeds_tamper_existing_terms_callback($result, $item_key, $element_key, &$field, $settings) { static $allowed = array(); if (!isset($allowed[$settings['vocabulary']])) { - // fetch all term names in the configured vocabulary + // Fetch all term names in the configured vocabulary. $allowed[$settings['vocabulary']] = db_query( 'SELECT td.name FROM {taxonomy_vocabulary} AS v @@ -95,8 +44,16 @@ )->fetchCol('name'); } + // Replace terms from the input field that are not in the allowed vocabulary + // with integer 0, so that they will be skipped by the taxonomy field mapping + // in taxonomy_feeds_set_target(). if (is_array($field)) { - $field = array_intersect($field, $allowed[$settings['vocabulary']]); - } else { - $field = in_array($field, $allowed[$settings['vocabulary']]) ? $field : ''; + foreach ($field as &$term) { + if (!in_array($term, $allowed[$settings['vocabulary']])) { + $term = 0; + } + } + } + else { + $field = in_array($field, $allowed[$settings['vocabulary']]) ? $field : 0; } }