I've feature module which have thousands of entries and I'd like to investigate which item is taking the longest time.

Currently all my features takes over 5h to revert, and I assume it's mainly because of rules config components which there are over 700 (10-20sec each rule, so it's like 2-3h for rules alone) in a single module, and over 200 exported entityforms (which also is slow). This is already after fixes, because before it was taking over 8-10h (before the MySQL stopped with gone away error), but this was due to the bug with infinite loop (some Entity+Rules conflict), so disabling entity_rebuild_on_flush variable at least worked in terms of finishing the process. This is especially trouble when you're reverting your features during each deployment or building your local environment on daily basis which takes 5h.

So my plan is to revert only rules which I need (e.g. via hook_update).

I'm aware that you can use features_revert to revert a single component:

features_revert(array('module' => array('component')));

however it takes forever and I would like to know if it is possible to revert only single entry (e.g. foo_my_rule_x) of a component (e.g. rules_config), in other words - a single line of feature module, for example:

features[rules_config][] = foo_my_rule_x

and not anything else, using a standalone code or drush.

  • Interesting! However, I wonder about the "however it takes forever": is that because of those "thousands of entries", or some other reason? Commented Jul 28, 2016 at 7:24
  • 1
    merci for the extra comment, also interesting! I think you should add that as an extra update to your question! Also, 700+ rules, interesting! Probably with hardly any custom code (since there is so much you can do with only rules IMO) ... Commented Jul 28, 2016 at 8:56

1 Answer 1


In order to revert, you need to remove a single component from the database, so the configuration from the code can be loaded instead.

So to revert a single rule, load the rule and delete it, e.g.

$rule = rules_config_load("my_rule");

This can be placed in hook_update().

Check Add drush rules-revert patch which provides such functionality for the drush command, e.g.

drush rules-revert my_rule

In addition, to revert all rules by not using Features module (which will take much quicker), you can try:

if ($rules = rules_config_load_multiple(FALSE)) {
  foreach($rules as $rule) {
    if ($rule->hasStatus(ENTITY_OVERRIDDEN) && !$rule->hasStatus(ENTITY_FIXED)) {

So by deleting the rules from the database, they're loaded from the code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.