Revert a Drupal feature during deployment
To revert a features module during deployment, add an update hook and call features_revert with the name of the module and the component you want to revert.
This will revert panels_mini in the features module called "my_module" when you run update.php
You can find the name of the components in the features .info file, as follows:
features[component][] = "name"
So for a mini panel called "my_mini_panel", the .info file would have this line:
features[panels_mini][] = "my_mini_panel"
Now once you have deployed your feature to a new server, you just need to run update.php. The feature will revert to its code version. You would do this if you have changed a feature in your development environment and re-exported to code.
Comments
Learn how to write custom Drupal modules
Does Drupal module development make your head explode and drive you crazy?
Why not learn from someone who has paved the way instead?
Sign up to Master Drupal 7 Module Development.
I am
This is handy, thanks a lot! Here's a little utility function which makes it a bit easier to completely revert features in an update hook:
https://gist.github.com/1925886
Thanks for the link to your gist Cameron. Looks good, I'm sure I'll use it. There is also a Drush hook to revert all features, which is handy if you want to revert everything in a deployment/rebuild.
Hi,
I what location would this code go in?
In the .install file of a custom module
Post new comment