diff --git a/features.drush.inc b/features.drush.inc index 9da547d..b407f5f 100644 --- a/features.drush.inc +++ b/features.drush.inc @@ -721,6 +721,7 @@ function drush_features_revert() { drush_log(dt('Current state already matches defaults, aborting.'), 'ok'); } else { + $components = _features_sort_components($components); foreach ($components as $component) { $dt_args['@component'] = $component; $confirmation_message = 'Do you really want to revert @module.@component?'; diff --git a/features.module b/features.module index ba5b9fe..d6413f4 100644 --- a/features.module +++ b/features.module @@ -933,6 +933,7 @@ function _features_restore($op, $items = array()) { } foreach ($items as $module_name => $components) { + $components = _features_sort_components($components); foreach ($components as $component) { // Invoke pre hook $pre_hook = 'pre_' . $restore_hook; @@ -1109,3 +1110,22 @@ function features_get_deprecated($components = array()) { } return $deprecated; } + +/** + * Sort the components array to put the user_permission component at the end. + * + * @param $components + * The array of components (component_info) from features_get_components typically. + * + * @return array + * The array of components after sorting. + */ +function _features_sort_components($components = array()) { + $key = array_search('user_permission', $components); + if ($key !== FALSE) { + unset($components[$key]); + $components[] = 'user_permission'; + } + + return $components; +}