Problem/Motivation

Disclaimer: I tried my best to search for related issue, instead of creating a duplicate, but I couldn't find one.

If we have field(s) associated with taxonomy term, values (with fields, field instance definitions) are getting exported properly, but not getting imported.

Steps

1. Install Drupal 7, enable uuid_features.
2. Go to admin/structure/taxonomy/tags/fields and add a new 'textfield'
3. Create new tag with some value for the new field.
4. Export tags and it's terms.
5. Your info file would look like this:

name = example
core = 7.x
package = Features
dependencies[] = features
dependencies[] = taxonomy
dependencies[] = text
dependencies[] = uuid_features
features[features_api][] = api:2
features[field_base][] = field_testing
features[field_instance][] = taxonomy_term-tags-field_testing
features[taxonomy][] = tags
features[uuid_term][] = 97fc9134-b9a0-4259-bb64-96e23df58357

6. Delete the 'tags' vocabulary, so that it gets created from the new module.
7. Now, place the module in sites/all/modules and enable it.

Expected:
'tags' vocabulary with the term and custom field value we added at step 3.

Actual:
'tags' vocabulary with the term, but no value for the custom field.

I have added the code to get the additional fields(attached patch), but still the values didn't get exported. After few hours of xdebug, found the the problem is because of the weight of uuid_features is -50 (@see uuid_features_enable) which makes the feature to pick all uuid_feature module's components first. So the uuid_term getting rebuilt before field and fied_base.

Proposed resolution

I am sure there is a reason why we set weight as -50 (@todo: add a documentation issue to update the reason in comment). But below patch works, only after updating the weight to something higher than 0.

Remaining tasks

discuss
agrree

User interface changes

N/A

API changes

well, not sure.

CommentFileSizeAuthor
#2 2566555-1.patch908 bytesvijaycs85
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vijaycs85 created an issue. See original summary.

vijaycs85’s picture

Title: Can't import taxonomy_term fields » Can't import taxonomy_term fields value
Status: Active » Needs review
FileSize
908 bytes

Initial patch...

dman’s picture

This is indeed an issue - Content provided in extra fields attached to terms does not get populated when the feature is enabled.

Reverting the feature immediately after enabling it does end up with the desired result.
As a work-around, placing a features_revert_module() into the hook_install for your feature is redundant, but works around the issue.

function myfeature_install() {
  features_revert_module('myfeature');
}

This patch here DOES make the problem go away. So yay.
But I agree, it would be good to know WHY the module thought it needed to be weighted -50

For experiments, and to demonstrate the problem, I provided a sample vocabulary feature of countries and states - that includes a custom field that should receive data.
Without this patch, the extra 'abbreviation' field does not get populated. With this patch, it does.
https://github.com/dman-coders/countries_and_states