available at admin/structure/features/lock, or maybe admin/structure/features/[feature_name]/lock

ui to select from components/items exported to given feature and "lock" them from being reverted/rebuilt on a given site, even manually (via _features_restore()).

Probably can only do it at a component level (e.g. "for feature x, do not revert/rebuild: field bases, user permissions"), and not an item level (e.g. for feature x, do not revert/rebuild user permissions y).

Motivation: less need for default content, by allowing anything the user wants to change to be locked but still able to run such things like fra .

However, this is NOT to replace features override (e.g. this is not to allowing people to disable reverting user permission Y then exporting it to a different feature and having both original and new enabled), though that does present an interesting idea.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mpotter’s picture

Hmm, I really like this idea. Would help prevent changes made on a site (like different config on production) from being overwritten by a re-build that does a feature-revert-all.

Rather than adding to the Recreate screen, perhaps a UI can be added to the feature list screen where each included component could have it's own checkbox for lock/unlock and have some sort of obvious color/style change to show which are locked? Not sure we need a whole new menu hook/page since the current View page already has all the needed information.

hefox’s picture

Branch 7.x-2.x-2047253

Defiantly needs some more work, code comments, function names, link titles, explanation, etc. but looks to be working so far.

Can see current ui in screenshot; just added it to the overview page. I figure replace the links with glp complaint padlock graphics.

hefox’s picture

Status: Active » Needs review
hefox’s picture

I sorta want it to say "I'm sorry Dave, I'm afraid I can't do that" when someone fr a locked thing

Grayside’s picture

Overall, this looks pretty solid. I haven't really reviewed it for specific UI design.

Architecture

As a matter of basic approach, this is providing UI and using variable storage. This means we are putting locking in the hands of a site administrator. This is a bit different slant than focusing on building features as a developer or site builder where some or all elements are locked by default.

The way this is built, site owners have the power to decide which upstream configuration changes to override and ignore. In the alternate way I mention, distribution creators would control which features/components are enforced and which are default.

Practical difference would be cooking the locking into the construction of the features/info file vs. the administration of the feature/variables.

I think both constituencies are valid, just want to make sure we know who we are empowering.

Code & String Review

  1. +++ b/features.admin.inc
    @@ -1367,6 +1371,66 @@ function features_feature_diff($feature, $component = NULL) {
    +
    

    Extra space

  2. +++ b/features.admin.inc
    @@ -1367,6 +1371,66 @@ function features_feature_diff($feature, $component = NULL) {
    + *   A loaded feature object to display differences for.
    

    Not sure exactly what differences this is talking about. How about: "Loaded feature object to be processed for component locking."

  3. +++ b/features.admin.inc
    @@ -1367,6 +1371,66 @@ function features_feature_diff($feature, $component = NULL) {
    + *   (optional) Specific component to lock for
    

    A specific component to lock.

  4. +++ b/features.admin.inc
    @@ -1367,6 +1371,66 @@ function features_feature_diff($feature, $component = NULL) {
    +function features_feature_lock_form($form, $form_state, $feature, $component) {
    

    features_feature_lock_confirm_form

  5. +++ b/features.admin.inc
    @@ -1367,6 +1371,66 @@ function features_feature_diff($feature, $component = NULL) {
    +  $question = $is_locked ? t('Are you sure you want to unlock this Feature @name (component @component).', array('@name' => $feature->name, '@component' => $component ? $component : t('none'))): t('Are you sure you want to lock this component?');
    

    1. Unlock/Lock confirmation message symmetry. Unlock names the feature and component, lock just says "this component".

    Also, way longer than 80 chars. Can we multiline this?

  6. +++ b/features.admin.inc
    @@ -1367,6 +1371,66 @@ function features_feature_diff($feature, $component = NULL) {
    + * Locks a feature.
    

    "Submit callback to lock components of a feature."

  7. +++ b/features.admin.inc
    @@ -1367,6 +1371,66 @@ function features_feature_diff($feature, $component = NULL) {
    +    drupal_set_message(t('Feature @name (component @component) has been unlocked.', array('@name' => $feature, '@component' => $component ? $component : t('none'))));
    

    What would it mean to say "Feature Awesome Blog (component none) has been unlocked"?

    Also, it might be clearer to read things that could be multiple words to wrap them in single quotes.

  8. +++ b/features.drush.inc
    @@ -725,8 +725,13 @@ function drush_features_revert() {
    +                drush_log(dt('Skipping locked @module.@component.', $dt_args), 'ok');
    

    I think this should be 'notice' or 'info'. It represents no change, therefore it's probably only of interest in verbose mode.

  9. +++ b/features.module
    @@ -167,6 +167,17 @@ function features_menu() {
    +    'description' => 'Lock a feature or components.',
    

    I can't think of a better description, but I think somewhere in the module README or admin page we need something to explain what locking means in greater detail.

  10. +++ b/features.module
    @@ -1109,3 +1137,46 @@ function features_get_deprecated($components = array()) {
    +function features_feature_locked($feature, $component = NULL) {
    

    Difference between features_feature_locked and features_feature_lock is too subtle.

    features_feature_is_locked and features_feature_lock?

hefox’s picture

Issue summary: View changes
FileSize
11.99 KB

Patch done while d.o was down, adding icons to links (not updated for stuff mention above)

Eric_A’s picture

Seems that commit a338503 is a slightly modified version of the patch in #4?

hefox’s picture

Yep, and that commit is to branch 7.x-2.x-2047253

Should update that branch for #6; I believe pushing was down when I was working on that patch. And I forgot I'd made a branch for this issue

hefox’s picture

Adding component level locking and allow rebuilding mode

7.x-2.x-2047253 is up to date with this patch.

  • mpotter committed bcb058e on 7.x-2.x authored by hefox
    Issue #2047253 by hefox: Added Provide way to "lock" a feature component...
mpotter’s picture

Status: Needs review » Fixed

Nice work! Committed this to the main 7.x-2.x dev branch. Did some testing here and it looks pretty good and very useful. Might want to add additional tweaks later, for example in the "drush fd" output to show a component is locked. But people can tweak that kind of stuff by adding new issues/patches.

Status: Fixed » Closed (fixed)

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

jaxpax’s picture

Love this Features feature!

BillyTom’s picture

The page about reverting features should be updated with this new information about features beeing lockable https://www.drupal.org/node/582680

nedjo’s picture

I added some basic notes to the documentation page at https://www.drupal.org/node/582680.