Problem/Motivation
Hi,
After enabling a feature, the features components are currently not rebuilded/reverted, after some debugging I found out that the hook_modules_enabled()
implementation wasn't working.
When a module gets enabled (in an update hook for instance), you usually want the components to be available immediately, it seems that features_modules_enabled()
tries to solve that problem but because of a wrong $reset
flag passed to features_load_feature()
nothing is happening (at least in my case).
So, I've found that Features module doesn't include necessary files when module(s) are being enabled.
This issue is quite tricky to reproduce, due to the fact that:
- By default Features are being rebuild on cache clear
- Usually modules are being enabled using UI (Modules page or update.php), so we have multiple requests to PHP and this issue doesn't occur
- This issue can be spotted using PHP CLI (i.e. Drush) only, because Drush executes it's commands in a single PHP request (probably, haven't checked), so it's essential that any code clears caches/includes files when needed (for example, when a new module is being enabled/disabled)
Steps to reproduce:
- Create an installation profile
- Create two features, each contains single taxonomy vocabulary
- Try to read exported via Features taxonomy vocabularies in profile's *.profile file. For example assign permissions to edit terms in both vocabularies
- Install site using Drush
- One of the vocabularies will not be available there, but it should (example with permissions will cause PHP fatal error)
Issue (features.module, lines 372-386):
if (!empty($items)) {
// Need to include any new files.
// @todo Redo function so can take in list of modules to include.
features_include_defaults(NULL, TRUE);
_features_restore('enable', $items);
// Rebuild the list of features includes.
features_include(TRUE);
// Reorders components to match hook order and removes non-existant.
$all_components = array_keys(features_get_components());
foreach ($items as $module => $components) {
$items[$module] = array_intersect($all_components, $components);
}
_features_restore('rebuild', $items);
}
Issue it self created by the fact, that features_include_defaults(NULL, TRUE)
runs before features_include(TRUE)
. So, Features module can't include file containing exported taxonomy vocabulary because it hasn't included file integrating Features with Taxonomy yet.
Patch attached. Please review.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#7 | features-hook_modules_enabled_include_file_issue-2143765-7.patch | 1.15 KB | Taran2L |
Comments
Comment #1
jsacksick CreditAttribution: jsacksick commentedComment #2
bojanz CreditAttribution: bojanz commentedComment #3
hefox CreditAttribution: hefox commenteddoes features_load_feature check enabled state and not return if not enabled? Or running module enable right after adding module to code base without any cache clearing so drupal knows about the feature?
Comment #4
bojanz CreditAttribution: bojanz commentedThe problem occurs in an update function after running module_enable().
Doing a drupal_flush_all_caches() makes no difference because the problem is in the static cache (and until #1983022: use drupal_static instead of static $cache lands there is no way to clear it separately either).
Comment #5
Taran2LI can confirm that this issue still exists, as #1983022: use drupal_static instead of static $cache has never landed to the codebase.
Steps to reproduce:
Comment #6
Taran2LI've run into this issue for the second time now :)
But this time, I believe I've found source of the issue. Unfortunately, provided patch doesn't work for me.
I will post detailed issue description and patch later today.
Comment #7
Taran2LSo, I've found that Features module doesn't include necessary files when module(s) are being enabled.
This issue is quite tricky to reproduce, due to the fact that:
Steps to reproduce:
Issue (features.module, lines 372-386):
Issue it self created by the fact, that
features_include_defaults(NULL, TRUE)
runs beforefeatures_include(TRUE)
. So, Features module can't include file containing exported taxonomy vocabulary because it hasn't included file integrating Features with Taxonomy yet.Patch attached. Please review.
Comment #8
Taran2LComment #9
joelpittetAdding details to the issue summary.
Comment #10
rootworkThe patch from #1 has been getting included in Commerce Kickstart since April 29, 2015. It seems like it, at least, is probably safe to commit, though perhaps #7 needs more of a review.
Comment #11
kedramonPatch #7 worked for me fine.
Looks like neither patch is included to release.