Active
Project:
Features
Version:
8.x-3.11
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
3 Dec 2018 at 19:21 UTC
Updated:
16 Jun 2020 at 18:43 UTC
Jump to comment: Most recent
Having an issue using \Drupal::service('features.manager')->import() inside a hook_update_N().
Features only imports the first feature, and skips the rest.
I've tried this:
$features = [
'feature_1',
'feature_2',
'feature_3',
'feature_4',
'feature_5'
];
\Drupal::service('features.manager')->import($features);
And also this:
\Drupal::service('features.manager')->import(['feature_1']);
\Drupal::service('features.manager')->import(['feature_2']);
\Drupal::service('features.manager')->import(['feature_3']);
\Drupal::service('features.manager')->import(['feature_4']);
\Drupal::service('features.manager')->import(['feature_5']);
Using either of these, only feature_1 gets imported. I’ve tried changing the order, to see if there is something problematic about any of the features, and that’s not the case. Whatever feature I put first, either in the array or the separated out code, gets imported, and the rest are ignored.
No errors in the logs at all.
Comments
Comment #2
gdevan17 commented@wluisi any updates on this? I am having the same problem with version 8.x-3.8. ty
Comment #3
gdevan17 commentedAdding the following two lines before the import declaration fixes the issue:
The fix is mentioned in the following Drupal ticket: https://www.drupal.org/project/features/issues/2852248 The ticket also mentions that the fix should no longer be necessary (comment #6) However, the problem does seem to persist in certain environments. Drupal version is 8.6.10
ty
Comment #4
dwkitchen commentedThis issue is still active in 3.11, used @gdevan17 solution in #3017765-3: \Drupal::service('features.manager')->import() inside a hook_update_N() only imports 1st feature
Comment #5
ricksta commentedTry a "foreach" loop: