It is possible to revert a single item of the component programmatically? 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' =&gt; 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.
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");
$rule-&gt;delete();


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-&gt;hasStatus(ENTITY_OVERRIDDEN) &amp;&amp; !$rule-&gt;hasStatus(ENTITY_FIXED)) {
      $rule-&gt;delete();
    }
  }
}


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