Installation profile: default features instead of overriden ones, by default
Most likely I am not the only one who has run into the problem: if an own Drupal 7 installation profile enables a feature (a module created with the help of Features), then it gets overridden even for the first visit to the site. How can we avoid this situation?
First of all, prepare our feature modules properly, so they will not have problems! Practically this means Kit compatibility, especially:
- do not add certain permissions to the feature;
- do not add certain variables to the feature; (and/or avoid using the Strongarm module for adding variables to the feature);
This is not enough by itself, though. We need the following as well:
- make the dependencies of the feature modules (those modules that are listed in the
dependenciesarray in feature modules'
.infofile) dependencies of the installation profile itself (add them to the
dependenciesarray in the installation profile's
- do not add the feature modules themselves to the dependencies of the installation profile;
- enable the feature modules at the end of the installation profile (preferably as a separate task) with
- since the feature modules would be still overridden at this time, all the components of all the feature modules should be reverted with
The explanation of the above is if a feature module gets installed in the same step with its dependencies, then the implementations of the modules'
hook_install() may run in an undesirable order. A typical example is the case of the variables added to the feature with Strongarm: the module that ships the variable originally may overwrite the value specified in the feature module. The straight consequence of this: the feature module shows up as overridden right after enabling it. (Not too incidentally the same scenario happens if one enables the feature via the UI instead of the installation profile.) The aforementioned technique helps avoiding this problem.