The features_get_component_states()
function in features.export.inc
has a $reset
parameter. This function calls features_get_components()
in features.module
, which also has a $reset
parameter. However, when the former function calls the latter, it doesn't pass on its parameter - instead, it always gets called with its default value (FALSE
).
I've built a custom Drush script, that performs a site install (using drush site-install
programatically), and that then immediately goes on to do a number of other things, including installing features. After installing my feature modules, I was using this code, which I thought would be sufficient to activate the features I'd defined:
// Features don't actually get enabled if we don't do this.
module_load_include('inc', 'features', 'features.export');
features_get_info(NULL, NULL, TRUE);
features_rebuild();
However, turns out that - because I'd enabled some feature-component-defining modules as part of the site install (e.g. menu module) - the above code didn't work, because it didn't make Features refresh its components list. Instead, I had to do this:
// Features don't actually get enabled if we don't do this.
module_load_include('inc', 'features', 'features.export');
features_get_info(NULL, NULL, TRUE);
features_get_components(NULL, NULL, TRUE);
features_rebuild();
Which did the trick for me.
Attached is a patch that would make my first code snippet actually work in my Drush script.
Comment | File | Size | Author |
---|---|---|---|
#6 | features_reset_components-1633442.patch | 584 bytes | kenorb |
|
Comments
Comment #1
mpotter CreditAttribution: mpotter commentedSeems pretty reasonable. The only place features_get_component_states is called with $reset=TRUE is in features.module around line 852 when dealing with a specific Drush case. Adding your patch could impact drush performance on that call so we need to do a bit more testing to make sure it's not a problem.
Comment #2
mpotter CreditAttribution: mpotter commentedComment #3
mpotter CreditAttribution: mpotter commentedLet's see if this passes automated testing.
Comment #5
hefox CreditAttribution: hefox commented(whether a function passes $reset paramater down depends on the function. It's not always desirable to reset fully => feature request. Whether it makes sense for this function I don't know as not looking at it atm)
Comment #6
kenorb CreditAttribution: kenorb commentedRe-roll.
Comment #7
mpotter CreditAttribution: mpotter at Phase2 commentedThis looks good. Since the Tests are actually passing reset=TRUE I think that is also a good test result.
Comment #9
mpotter CreditAttribution: mpotter at Phase2 commentedCommitted to 166b2ce.