When importing terms with "create_term" enabled, case-variations on existing terms result in both the existing term (with the wrong case) and a new term (with the correct, updated case) being added to the taxonomy term reference field.

In my migration, I have:

 $this->addFieldMapping('field_term_topic', 'topic')
   ->description(t('Topic'))
   ->arguments(array('create_term' => TRUE));

I have an existing taxonomy term named "Social conditions", but the migration data now has the term "Social Conditions".

Both terms get included in the migrated field because the database query that gathers existing terms is case-insensitive; a new term is created if there is no exact case-sensitive match found, but all matches are ultimately added to the field. In my case, the field will contain both "Social conditions" and "Social Conditions", even though only the latter is specified in the data.

I'll post a patch shortly.

Comments

becw’s picture

I don't think this issue is related to #1308268: Terms get duplicated with MigrateDestinationTerm, which is about exact, case-sensitive duplication of terms.

becw’s picture

Assigned: becw » Unassigned
Status: Active » Needs review
StatusFileSize
new2.23 KB

Here's a patch.

mikeryan’s picture

Category: bug » feature
Status: Needs review » Needs work

I don't think Migrate should presume to fold terms of different cases together - if the source data for a migration has "Drupalcon" and "DrupalCon" terms, the default behavior should be to replicate that. If there is to be a case-folding feature, it should be enabled by an argument.

becw’s picture

This patch doesn't do case folding--it makes sure that the case of the term added to the node exactly matches the case of the data.

becw’s picture

Status: Needs work » Needs review
mikeryan’s picture

Status: Needs review » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Clarified what happens in my example.