There's one function (features_revert()) to do anything between revert 1 component in 1 feature and revert all components in all features. There's no function that reverts all components in 1 feature. I miss that. Is that something to add?

I'm currently using this in update hooks a lot:

<?php
function features_revert_module($module) {
    if ((
$feature = feature_load($module, TRUE)) && module_exists($module)) {
       
$components = array();
        foreach (
array_keys($feature->info['features']) as $component) {
            if (
features_hook($component, 'features_revert')) {
               
$components[] = $component;
            }
        }
       
features_revert(array($module => $components));
    }
}
?>

Idea?

Files: 
CommentFileSizeAuthor
#8 features-revert_single_module_1_x-1871986-7714267.patch846 bytesceng
Test request sent.
[ View ]
#6 features-revert_single_module_doc-1871986.patch590 bytesceng
Test request sent.
[ View ]
#3 features-revert_single_module-1871986.patch846 bytesceng
Test request sent.
[ View ]

Comments

I Just used this function for the same scenario and thought it would make a worthy addition. Thanks!

I also used this a couple of times, very handy!

Status:Active» Needs review
StatusFileSize
new846 bytes
Test request sent.
[ View ]

I've been using this for a while now - here is the patch attached.

As stated already, this means you can do the following in your install file hook_update_N functions...

/**
* Revert all features in myfeature.
*/
function mymodule_update_7001() {
  features_revert_module('myfeature');
}

Version:7.x-1.x-dev» 7.x-2.x-dev

Moving this to 2.x to get it to pass testing (no reason it shouldn't pass though)

Status:Needs review» Fixed

Actually, just going to commit this (293fda6). I use this function all the time in my own projects and have been meaning to add it to Features for a while.

Somebody want to write a documentation patch?

StatusFileSize
new590 bytes
Test request sent.
[ View ]

Where would the documentation go? Attached is a note at the end of API.txt if it helps.

Any change this getting into 1.x? I don't like 2.x.

Version:7.x-2.x-dev» 7.x-1.x-dev
Status:Fixed» Needs review
StatusFileSize
new846 bytes
Test request sent.
[ View ]

Backport patch for 7.x-1.x is attached. I've tested this out on a basic D7 install and appears to work fine.

Shouldn't this go in 7.x-2.x-dev and get backported to 7.x-1.x-dev?

It has hasn't it? mpotter committed in #5

Version:7.x-1.x-dev» 7.x-2.x-dev
Status:Needs review» Fixed

TMK, there's no plans to backport items to 1.x branch (unless it's a security issue). Use 2.x, it's much better

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Issue summary:View changes

color coding