Problem/Motivation

It should be possible to rerun feature assignment at any time within a given bundle and have the resulting features reflect the (potentially, altered) assignment configuration.

However, currently, the 'existing' assignment plugin has a low default weight of -10. This means that, on regeneration, changes made to other assignment plugins will not be have the desired effect of reassigning configuration that's already been assigned.

Proposed resolution

Give the 'existing' plugin the highest default weight.

See also #2446805: Add "required" components for a given feature, which would be a necessary complement to this fix.

Remaining tasks

User interface changes

API changes

Comments

mpotter’s picture

Category: Bug report » Feature request

No, I think the way it is now is how we want this to work.

If configuration has already been exported to a Feature module, then you don't want assignment plugins to change that by default. Otherwise you could easily end up messing up existing Features unintentionally.

Of course, you can always create your own bundle and then re-order the assignment plugins if you have a use-case for moving stuff around. The beauty of assignment plugins and bundles!

But I think the default for the vast majority of Features users is correct since it reflects what people are used to from D7. I'd like the power of assignment plugins to be a more advanced feature that people don't need to worry about if they just want to use Features the way they did before.

nedjo’s picture

It should be possible to rerun feature assignment at any time within a given bundle and have the resulting features reflect the (potentially, altered) assignment configuration.

This is the key question here. As originally designed, assignment plugins are not for one-time use (only when creating a feature for the first time). Rather, it should be possible at any time to tweak them and rerun them, which should result in items being reassigned from one feature to another.

For this to work, though, we can't immediately redo all existing assignments. As things stand, tweaking the settings after the initial features export will have little or no effect.

If configuration has already been exported to a Feature module, then you don't want assignment plugins to change that by default. Otherwise you could easily end up messing up existing Features unintentionally.

I think you do want assignment plugins to change that by default, but you also want a way to ensure that specific items are not reassigned. Hence the need for #2446805: Add "required" components for a given feature.

I'm seeing it like this:

  • I generate a feature.
  • Whenever I manually add or remove an item it's marked as required or excluded.
  • When I regenerate a feature, the required/excluded plugin runs early (where the existing one now runs) and ensures that any previous explicit assignments are retained. Then the existing plugin runs late, to ensure that any leftover assignments are remade.

So the fix looks to me like:

  • Mark this issue as postponed, since it depends on #2446805.
  • Complete #2446805.
  • After that, this can be reopened.

More generally:

I'd like the power of assignment plugins to be a more advanced feature that people don't need to worry about if they just want to use Features the way they did before.

While I see the attraction of familiarity, I think we should aim to significantly improve features approaches in D8. D7 features in general are a mess. They are so arbitrarily structured as to make interoperability a statistical impossibility. By baking in sound design principles, we can provide the basis for better practices. And for this to work, we need to the ability to reassign after initial features generation.

mpotter’s picture

Another thing to keep in mind is working on sites with existing Features from a distribution (my main use-case). If Open Atrium provides a lot of Features, I don't want changes in my assignment plugins to effect those. You don't want people regenerating those existing features from the distro.

So I think we have multiple use-cases here. As I mentioned, the nice thing about Bundles and Assignment Plugins is that people can change this. They can move the Existing plugin to the bottom of the list if they want.

But you are correct that we can't do any of that without #2446805. Maybe with that the distro case would be handled by just locking all of the Features. But I'm not sure I'm going to want to lock each and every individual component. Rather I'll want something like a locked Feature.

Maybe we could handle this easier to start with if we just had a "Locked" feature config and have an Assignment Plugin exactly like the current "Existing" plugin that loaded any locked Feature at the beginning.

I generate a feature.
Whenever I manually add or remove an item it's marked as required or excluded.
When I regenerate a feature, the required/excluded plugin runs early (where the existing one now runs) and ensures that any previous explicit assignments are retained. Then the existing plugin runs late, to ensure that any leftover assignments are remade.

That still doesn't work for my common use-case with working on Open Atrium features. My workflow is currently:

  • Create a new content type, views, etc
  • Create a new Feature based on this content type. All fields, views, etc get auto-detected.
  • Now I don't want that Feature to change. Custom code added to the module will depend on those fields, etc being part of the module.
  • Since I didn't "manually add" these items, they wouldn't have gotten marked as "required" and a site builder using Atrium could still inadvertently move stuff out of the distro's features breaking their site.
  • So instead of having the config marked as "Required" I would just lock the entire Feature.
nedjo’s picture

Since I didn't "manually add" these items, they wouldn't have gotten marked as "required"

Yeah, I think we need a way to explicitly mark a config item as required. I guess there are three states: required, excluded, and default.

This would be similar to the locking as available in D7, except that the state is saved with the feature export, not as a local variable on each install.

a site builder using Atrium could still inadvertently move stuff out of the distro's features breaking their site

This shouldn't be a risk because the reassignment should only happen within a given bundle. The exclude assignment plugin with its default settings should ensure that any configuration provided by modules outside of the current bundle isn't available for assignment.

nedjo’s picture

nedjo’s picture

  • nedjo committed 5e52b14 on 8.x-3.x
    Issue #2490888: move "existing" plugin to run late to allow...
nedjo’s picture

Status: Postponed » Fixed

#2596047: Duplicate packages generated is now fixed, which cleared the way for this change.

Status: Fixed » Closed (fixed)

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