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.
Comment | File | Size | Author |
---|---|---|---|
#9 | features-1986316-9-Allow-conflicts.patch | 11.92 KB | geek-merlin |
Comments
Comment #1
louisnagtegaal CreditAttribution: louisnagtegaal commentedIn my experience conflicted Field Bases (field_base) and Field Instances (field_instance) are added correctly, but
are not. In my case the files related to the first 2,
were not present and were not created when I generated or downloaded the feature.
Comment #2
ohthehugemanatee CreditAttribution: ohthehugemanatee commentedConflicting 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...
Comment #3
ohthehugemanatee CreditAttribution: ohthehugemanatee commentedI 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.
Comment #4
geek-merlin#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()
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)
Comment #5
geek-merlinThis is a showstopper to use features with defaults like from commerce, so raising prio.
(Maybe it's a dup but couldn't find.)
Comment #6
geek-merlinTO 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
Comment #7
geek-merlinMade a plan in the summary.
Comment #8
geek-merlinComment #9
geek-merlinPatch 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.
Comment #10
geek-merlinI 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).
Comment #11
ordermind CreditAttribution: ordermind commentedPatch #9 is working for me.
Comment #12
mpotter CreditAttribution: mpotter commentedI 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)
Comment #13
jmdeleon CreditAttribution: jmdeleon commentedThe 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.