Problem

Analysis

OK, this might be a tough ride through all features export hooks:

Looks bad

* entity_features_export delegating to EntityDefaultFeaturesController::export (lives in entity so separate issue)
* ctools_component_features_export
* field_features_export
* field_group_features_export_alter (separate issue)
* image_features_export
* menu_custom_features_export
* menu_links_features_export
* node_features_export
* og_features_permission_features_export & og_features_role_features_export (separate issue)
* taxonomy_features_export
* user_role_features_export
* views_features_export

Looks good (untested unless noted)

* variable_features_export
* filter_features_export
* flag_features_export
* language_features_export
* wysiwyg_features_export

Further Steps

All the above "looks bad" functions discard conflicts and add dependencies to providing modules instead.
This once may have made sense, but now, as the UI cares for conflict resolution we should rip out all that conflict checks.
(We might add a warning/feature ro raise weight of the feature module, but that's another issue.)

Original Report

I'm trying to refactor my features a bit - I'm in the process I am creating some new features that for the moment conflict with others.

I've gone through a few iterations of this scenario:
1. Start creating a feature
2. I have "Allow conflicts to be added" as checked
3. I've added several components, some that show as conflicting, other that don't.
4. I download the feature and take a look at it - only the elements that were not conflicting end up in the feature code.

So far I can see this behavior occurs at least with field groups and contexts, but I'm guessing it happens with all types.

Looks like the ability to re-export conflicted components was added in #1219256: Show Feature's conflicts at the export form, so I think my interpretation of how this is supposed to work is correct.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

louisnagtegaal’s picture

In my experience conflicted Field Bases (field_base) and Field Instances (field_instance) are added correctly, but

  1. Fieldgroup (field_group)
  2. FlexSlider (flexslider_optionset)
  3. Image styles (image)

are not. In my case the files related to the first 2,

  • .field_group.inc
  • .flexslider_default_preset.inc

were not present and were not created when I generated or downloaded the feature.

ohthehugemanatee’s picture

Conflicting Views and Strongarm elements aren't exported either. It looks like anything that uses the hook_whatever_api plugin structure doesn't export conflicts.

Still investigating...

ohthehugemanatee’s picture

I thought this through a little more, and basically the problem is that only Features has a way to deal with conflicts. Ctools, Views, Strongarm, etc do not. If you have two modules that define the same View, Views does not have a system to show that to the administrator and let them decide which version to use.

So this is actually probably a problem for those various contributed modules.

geek-merlin’s picture

Issue summary: View changes

#3: this might sort out by module weight, but did not check the code for that.

debugged this a bit by selecting a conflicting and a nonconflicting rule. looks like the problem is in features_populate(), it gets both rules and spits out only one.

It looks like in _features_populate()

    if (!empty($data) && $function = features_hook($component, 'features_export')) {
      // Pass module-specific data and export array.
      // We don't use features_invoke() here since we need to pass $export by reference.
      $more = $function($data, $export, $module_name, $component);

this calls e.g. entity_features_export() which delegates to \RulesFeaturesController::export() which only spits out DB content.

Of course we could take features_get_default($component) and trick it into $export, but we had to duplicate dependency handling of the export controller.

EDIT: I came to this by debugging and it looked like that features hook got an "order" for the conflicting elements but did not serve them (tested with rules that uses said entity controller)

geek-merlin’s picture

Priority: Normal » Critical

This is a showstopper to use features with defaults like from commerce, so raising prio.
(Maybe it's a dup but couldn't find.)

geek-merlin’s picture

TO clarify some findings and guessings:
* Gues this bug DOES happen with Entity API exportables (tested rules using RulesFeaturesController, as well as message type using EntityDefaultFeaturesController)
* Gues this bug DOES happen with Ctools exportables (tested with views)
* Gues this bug DOES NOT happen with Faux exportables (tested with field bases)

If the bug happens, the object is not written to hook and not in info file.

This bug happens with features conflicts (marked red by features) as well as other code defaults (maybe from commerce) which leads to user selections silently and unexpectedly dropped.

The called functions are
* ctools_features_export
* entity_features_export() => EntityDefaultFeaturesController->export()
** RulesFeaturesController
** also: PaymentMethodFeaturesController

geek-merlin’s picture

Version: 7.x-2.0-beta2 » 7.x-2.x-dev
Issue summary: View changes

Made a plan in the summary.

geek-merlin’s picture

Issue summary: View changes
geek-merlin’s picture

Status: Active » Needs review
FileSize
11.92 KB

Patch flying in that might fix the issue for our hooks.
It looks heavier than it is, because ripping out conditions changes indentation.

Also added child issues in the other projects.

geek-merlin’s picture

I can confirm this patch does what it announces on all 25 component types on my system (this includes test of the crosslinked entity patch, but not og).

ordermind’s picture

Patch #9 is working for me.

mpotter’s picture

Priority: Critical » Normal
Status: Needs review » Needs work

I think this patch needs to actually check the value of the "Allow conflicts" option before doing all of this. This is such a heavy change that I really worry about it for normal users. For example, if Allow Conflicts is disabled, you *want* the behavior that adds dependencies rather than exporting the conflicting config.

For example, people using Features via Drush are not going to expect this large change in how stuff is exported.

(Also, this is far from a "critical" issue)

jmdeleon’s picture

The patch in #9 also worked for me. It allowed me to refactor a module and resolve conflicts manually, breaking it up into simpler component modules.