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.

Comments

mpotter’s picture

Seems 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.

mpotter’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Needs review » Needs work
mpotter’s picture

Status: Needs work » Needs review

Let's see if this passes automated testing.

Status: Needs review » Needs work

The last submitted patch, features_reset_components.patch, failed testing.

hefox’s picture

Category: bug » feature

(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)

kenorb’s picture

Assigned: Jaza » Unassigned
Status: Needs work » Needs review
StatusFileSize
new584 bytes

Re-roll.

mpotter’s picture

Status: Needs review » Reviewed & tested by the community

This looks good. Since the Tests are actually passing reset=TRUE I think that is also a good test result.

  • mpotter committed 166b2ce on 7.x-2.x authored by kenorb
    Issue #1633442 by Jaza, kenorb: features_get_component_states() should...
mpotter’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 166b2ce.

Status: Fixed » Closed (fixed)

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