Download & Extend

Fieldgroups disappear after disabling/reenabling a Feature

Project:Features
Version:6.x-1.1
Component:Code
Category:bug report
Priority:minor
Assigned:Unassigned
Status:active
Issue tags:fieldgroup

Issue Summary

If you add a fieldgroup to a feature and disable your module, when you re-enable it, the fieldgroup will have disappeared and your feature will appear to be overridden - specifically, the fieldgroup will appear to have been removed.

This happens because the logic for determining the state of the feature (needs rebuilding, default, overridden) is determined by looking at the current state of the component (in this case examining the fieldgroup tables) and building the code export, then checking that against the features code-cache. If the feature has never been enabled before, the correct behavior happens - the feature is rebuilt from code (features_fieldgroup_rebuild($module)). On disable, however, the fieldgroup will notice that all its fields are disabled and delete itself. It's therefore gone from the database, and when it's time to re-enable the feature, that fieldgroup is gone. Since there is a value in the codecache, Features sees this as an override.

There doesn't seem to be any straightforward way to solve this issue that I can find. As a workaround, you can call rebuild in your feature's enable hook, e.g.

function my_module_enable() {
    features_fieldgroup_rebuild('my_module');
}

If there's a general way to solve this, wonderful! But mostly I'm just posting this for the benefit of other people that run into this issue. It might be worthwhile adding this to some documentation somewhere as well, but I don't know where the proper place would be.

Comments

#1

subscribing

#2

This sounds like a field group bug due to the fields are not gone, they're disabled, so deleting the field group seems like an incorrect action? (wait, is it features calculating the fields are gone and deleting it?)