Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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?
Comment | File | Size | Author |
---|---|---|---|
#8 | features-revert_single_module_1_x-1871986-7714267.patch | 846 bytes | johnennew |
#6 | features-revert_single_module_doc-1871986.patch | 590 bytes | johnennew |
#3 | features-revert_single_module-1871986.patch | 846 bytes | johnennew |
Comments
Comment #1
gavin.hughes CreditAttribution: gavin.hughes commentedI Just used this function for the same scenario and thought it would make a worthy addition. Thanks!
Comment #2
FreekyMage CreditAttribution: FreekyMage commentedI also used this a couple of times, very handy!
Comment #3
johnennew CreditAttribution: johnennew commentedI'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...
Comment #4
mpotter CreditAttribution: mpotter commentedMoving this to 2.x to get it to pass testing (no reason it shouldn't pass though)
Comment #5
mpotter CreditAttribution: mpotter commentedActually, 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?
Comment #6
johnennew CreditAttribution: johnennew commentedWhere would the documentation go? Attached is a note at the end of API.txt if it helps.
Comment #7
rudiedirkx CreditAttribution: rudiedirkx commentedAny change this getting into 1.x? I don't like 2.x.
Comment #8
johnennew CreditAttribution: johnennew commentedBackport patch for 7.x-1.x is attached. I've tested this out on a basic D7 install and appears to work fine.
Comment #9
alexweber CreditAttribution: alexweber commentedShouldn't this go in 7.x-2.x-dev and get backported to 7.x-1.x-dev?
Comment #10
johnennew CreditAttribution: johnennew commentedIt has hasn't it? mpotter committed in #5
Comment #11
hefox CreditAttribution: hefox commentedTMK, there's no plans to backport items to 1.x branch (unless it's a security issue). Use 2.x, it's much better
Comment #12.0
(not verified) CreditAttribution: commentedcolor coding
Comment #13
scott.whittaker CreditAttribution: scott.whittaker commentedThis doesn't seem to be present in 7.x-2.0-beta2
Comment #14
GuyPaddock CreditAttribution: GuyPaddock at RedBottle Design, LLC for Inveniem commentedLooks like this is now an API function:
http://www.rit.edu/drupal/api/drupal/sites%21all%21modules%21features%21...
Comment #15
core44 CreditAttribution: core44 commentedLink dead, here's another...
http://api.drupal.psu.edu/api/drupal/modules%21contrib%21features%21feat...
Comment #16
generalredneckThrowing in a true permalink
https://git.drupalcode.org/project/features/-/blob/bab2d219b10092c74c35a...