Maybe this is the nature of features, but I have created a feature component based on a ctools exportable. When I implemented an alter hook for my default exportables callback I noticed that the features page always shows the component as being overriden.
After going through the features code I narrowed it down to the fact that the 'normal' signature uses the export render, which in turn calls ctools_export_load_object which invokes the alter. This is how I would expect the function to work.
The 'default' signature is directly calling the default callback, and does not invoke the alter.
So, even though there is no version of the object in my database, the two signatures differ because one invokes the alter, and one does not.
My question is: Is this "working as intended" (should altered defaults be considered Overriden)?
If not, should the 'default' signature included an invocation to the alter?
| Comment | File | Size | Author |
|---|---|---|---|
| #63 | features-alter_overrides-766264-63.patch | 2.9 KB | grndlvl |
| #56 | interdiff.txt | 1.46 KB | rodrigoaguilera |
| #56 | features-alter_overrides-766264-56.patch | 2.95 KB | rodrigoaguilera |
| #54 | features-alter_overrides-766264-54.patch | 2.91 KB | basillic |
| #45 | alter_overrides-766264-45.patch | 2.47 KB | Anonymous (not verified) |
Comments
Comment #1
jonskulski commentedMy opinion that is is not working as intended. Alters are not part of the export by definition.
The 'correct' semantic solution, in my opinion, is to not have the 'normal' signature be altered. But since that is ctools and other modules job (which they do correctly), the solution is to also allow alters to the default items.
Comment #2
te-brian commentedDo you think it is as simple as adding a drupal_alter(my_exportables_default_callback) to the bottom of the signature check, or would this have ruinous effects on the feature modules that are out there already?
Comment #3
jonskulski commentedWell that's certainly the path. I feel there may be dragons, i.e. the default drupal_alters are not named the same as the hooks. But its worth some investigation.
Comment #4
jhedstromSubscribing. Marked #810158: if hook_views_default_views_alter() is implemented, features always detects view in an overridden state as duplicate.
Comment #5
yhahn commented#766264: Alter hooks causing status to always be overridden
Comment #6
jhedstromRe-opening this because I think it was mistakenly closed as a duplicate of itself.
Comment #7
jhedstromNever mind, it is a duplicate of #838612: Remove Alterifications from export.
Comment #8
tarmstrong commentedI don't consider this a duplicate of #838612: Remove Alterifications from export, but it is worth noting that they are very closely related.
Here's a patch that solves this problem for me. When doing 'overridden-ness' checks, I make sure no alter hooks run. This makes sense to me, because if you're going to call alter hooks on one, you should do it on both. The opposite is easier to implement, and will probably make the #838612: Remove Alterifications from export people happier.
Thoughts?
Comment #9
mrfelton commented@tarmstrong - this does indeed seem to stop default alterations from being re-exported, however the features still appear as 'overridden' when using
drush flComment #10
hefox commentedWorking on tests in http://drupal.org/node/1402312#comment-5472904 comment that test for altering, and the tests for true exportables (views, image) are failing, whereas the ones for faux exportables (features provided, user_permission, filter, field) are passing.
Comment #11
Sarenc commentedIt seems the alter hooks remain "Overridden" when they add a new item to the exportable array. An example is hook_content_default_fields_alter() - you can alter an existing field all you want but adding a new one will prevent the "Overridden" message from disappearing. Same for hook_user_default_roles_alter().
For these two examples, if you have added roles or fields to the database your feature will appear overridden. If you add the new roles/fields into the alter hook reverting the component will include your alters but the "Overridden" message remains.
Comment #12
hefox commentedI think adding an item during alter stage isn't necessarily supported; alters are for altering existing, not adding new. It's possible cause it's possible, but it breaks how features knows about components and don't think getting features to work with it is a good effort. (there's a patch in views issue queue that is moving views to that (views added during alter won't work).
Comment #13
tom friedhof commentedThe patch in #8 doesn't work with faux exportables. If I add an alter to add new perms using hook_user_default_permissions_alter(), it never actually pulls my new perms into the DB.
Comment #14
zhangtaihao commentedIt almost seems like Features is simply detecting overrides where none exists as far as it is (or should be) concerned.
My take on it is that Features shouldn't care about components it isn't aware of, i.e. exported in the info file. Someone please correct me if this has already been decided otherwise somewhere else, but Features itself should only compare observed exports.
In this line of reasoning, it no longer matters whether CTools or some other module is altering the normal/default on its own. Features couldn't care less about added components when determining the signature. However, this would still allow faux exportables to be rebuilt using the entirety of the altered defaults.
A potential caveat is that Features will no longer detect changes to faux exports added via an alter hook. Whenever extra faux exports are modified, the module update or the administrator shall have to rebuild (now possible in Drush with #1721366: Drush features-revert should detect/revert FEATURES_REBUILDABLE components (features_revert() does)).
EDIT: It should also be possible to force Features to pick it up via
hook_system_info_alter().Comment #15
zhangtaihao commentedLet's do it on 7.x-1.x first.
Comment #16
zhangtaihao commentedForgot to change status.
Comment #17
zhangtaihao commentedDeclaring the dynamic exports
hook_system_info_alter()wouldn't work for components like image styles. Feature modules providing image styles without exporting them as features, i.e. by implementinghook_image_default_styles()in the module file, are shown as overridden if the hook doesn't return the full info, i.e. with all the effect info filled in.Seems like excluding everything not included in
features[...]in the info file is still the way to go.Comment #18
zhangtaihao commentedUpdate: Completely suppress empty exports.
Comment #19
mrfelton commentedThis works pretty well. Image styles (hook_image_default_styles) still report as overridden though when a module implements hook_image_styles_alter().
Comment #20
zhangtaihao commentedYes, I've run into that too, though I thought I had fixed it in #18.
Can you tell me if the hook_image_styles_alter() implementation adds/removes anything?
Comment #21
mrfelton commented@zhangtaihao - no, it just alters the width and height of existing styles.
Comment #22
mrfelton commentedAlterations added with hook_strongarm_alter also still appear in the features exports.
Comment #23
drupal_was_my_past commentedJust wanted to chime in to say that #18 fixes the always overridden problem that gets introduced with the latest file entity and media_youtube dev versions where defaults are introduced via
hook_file_default_displays_alter().Comment #24
mpotter commentedSomeone will need to resubmit a patch rolled against the 2.x branch for this to be considered. The 1.x branch is frozen.
Comment #25
devin carlson commentedA straight reroll of #18 against the 2.x branch for testing.
Comment #26
mpotter commentedThis is also going to need some testing with the Features Override module. Can somebody let me know if this patch changes any interaction with that module? Got my hands full with releases right now.
I plan to wait a couple of weeks to make sure the Features 2.0 release is solid before embarking on any new changes for 2.1-dev. So we have some time to work on this one.
Comment #27
dagomar commentedSo far looking good. Will need to test with Features Override though.
Comment #28
alexkb commentedWith alpha3 (25th Oct) of file_entity, which implements hook_file_default_displays_alter(), and #25 patch for features, we're still seeing the image_style of image__default__file_field_image as overridden, after a drush cc all, and a re-export of the feature.
Comment #29
jstollerI just killed a couple hours trying to figure out why the feature module with my media module configuration in it kept being listed as overridden, no matter what I did. I'm using:
I installed the patch from #25 and suddenly Features was happy. No overrides reported.
@alexkb, I seem to be using the same version of File Entity as you and I'm not seeing that error. Are you still having problems with this patch, or can we mark it RTBC?
Comment #30
alexkb commented@jstoller are you making changes to the default view modes of default file entity types like the image?
Comment #31
hefox commentedI think this patch needs test added for it, specially one that reproduces the bug and show that it is fixed via this.
Comment #32
jstoller@alexkb: I added a couple new fields to the default Image, Audio and Video file types. I went through each of the display modes (default, teaser, preview) on both the "Manage Display" and "Manage File Display" tabs for all four default media types. For each one I at a minimum hit the save button, so Drupal thought I was overriding it, but in several cases I made changes, particularly with my new fields. I then added all relevant field_base, field_instance, file_display, and Strongarm variable instances to a feature. In all, I think I have 55 file_display values in there from file entities. Before applying the patch I was getting a number of different "overridden" errors across the file entities. After applying the patch, there are no errors.
Comment #33
eric_a commentedComment #34
ericclaeren commentedI'm on features 2.0 and the patch in #25 worked partially, I now can export file entity image defaults but it keeps overridden for one style. I have changed the display of the image > teaser with a custom image style. Although the style is in the code of the feature, it reports overridden .
VS override
Comment #35
kristiaanvandeneyndeI can confirm that the patch in #25 works for me.
The issue that dreamlabs is encountering in #34 is because the File Entity module is providing a polyfill for the Image module by introducing this function in file_entity.module:
This is actually an _alter() function so should not interfere with the calculation of overridden states after applying the patch from #25.
Comment #36
kristiaanvandeneyndeUpdated the above answer and wanted to shed some more light on this issue.
My recent findings show that a lot of related issues are about people not being able to export Media, File Entity and the like entities. This is because they are trying to export entities already provided by a defaults hook.
Media used to provide its defaults through hook_file_default_displays() but moved away from that approach in favor of hook_install(). See: #1702700: Implementation of hook_file_default_displays makes it impossible to export image display settings via features
File Entity and Media Vimeo (AFAIK) still provide default displays through that hook instead of installing them when the module is installed. This leads people to editing the 'provided defaults', thinking they can still export them afterwards.
Solution: Clone the 'default' entities, disable the 'defaults' and work with the clones. After applying the patch in #25, nothing can stop you from having clean, working features with Media, File Entity and the likes :)
Comment #37
hefox commentedSolution: use features overrides (or fix whatever is preventing features override to work in this case). Works for default views, tmk.
Comment #38
dagomar commented@hefox
Features override does not work for me in this case. Should it be in a different feature then the one in which I am trying to set the default file setttings?
[edit] I just tried to put everything in a second feature, that is still not working.
[edit-2] I think I misunderstood the comment from @hefox as it was in reply to another problem. #25 (still) works for me.
Comment #39
kristiaanvandeneyndeDoes Features Override work when the original exportable is not provided through Features, but the code of a 'regular module'?
(As is the case for File Entity, Media Vimeo, etc.)
Comment #40
leex commented@37 not that I can see. I have the catalog view provided by uc_catalog and when I customize it none of the changes show up in FEATURE OVERRIDES or FEATURE OVERRIDES (INDIVIDUAL -- ADVANCED).
I believe it's because the view is not provided by a feature but hook_views_default_views.
I wish I was able to export this override! I'm guessing I'm going to need to hook_views_default_views_alter() to get it in code.
Comment #41
kristiaanvandeneynde@leex (#40)
Yes, that is exactly how it can work:
Comment #42
robloachI like this patch. It makes me warm and fuzzy. +1
Comment #43
robloachHowever, this does not take affect on a
drush fu.Comment #44
caschbre commentedI'm attempting to use patch #25 to get around a hook_default_rules_configuration_alter() causing one of my features to always show as overridden. The rule is provided by the commerce module(s) and I'm simply trying to disable it.
When I applied the patch I was no longer seeing the issue overridden because of that alter hook. But now I'm getting a different override against defaultconfig.
Any ideas?
Comment #45
Anonymous (not verified) commentedI found an issue with exports created by fe_block adding a version #. I added code for that and then re-rolled against latest dev version.
Comment #46
kristiaanvandeneyndeCould you provide an interdiff.txt? Makes reviewing the changes between #45 and #25 easier.
Comment #47
stewart.adam commented@rsmylski seems to have only modified this section of the patch - original patch (#25):
New patch (#46):
Comment #48
jstollerMarking Needs Review to trigger the testbot. I just tested the patch from #45 and it worked for me.
Comment #49
sagannotcarl commented#45 worked great for me.
Comment #50
coredumperror commented#45 also solved the problem for me!
Comment #51
uhkis commented#45 works. Even applies to 2.2. (With some offsets)
RTBC imo.
Comment #52
Marco Vervoort commentedI tried to use patch #45, and while it resolved the problem I had with features exporting file_displays, it caused problems with another feature that exported styles (from the 'styles' module). The 'styles_style' component always registered as overridden, with the 'diff' claiming that there was no 'standard' content, in spite of it being present in the 'mymodule.features.inc' file.
I investigated, and this appears to be due to the structure of $objects for the styles_style component. For instance, the style definition for 'file:article_half' can be found in $objects["file"]["styles"]["article_half"] rather than $objects["file:article_half"].
If I replace the 'array_intersect_key' line of patch 45 with
everything works.
Comment #53
basillic commented@MRV, can you post a patch of your changes, please ?
Comment #54
basillic commentedPatch #45 + last comment of @MRV.
This patch (or #45) produces a curious side effect with some featured taxonomy terms. It needs more investigations.
To summarize quickly: a Feature, whose status is 'Default' without this patch, is marked as 'Overridden' with this patch for some taxonomy terms.
Comment #55
hefox commentedneeds review based on above comment, also simple code style issue/s ( } else {)
Comment #56
rodrigoaguileraFixed code style.
AFAIK taxonomy terms can not be exported with solely this module.
Maybe you meant taxonomies but I don't experience any issue with this.
For me the patch is ready to go and I use it daily.
Comment #57
izmeez commentedThe patch applies to features-7.x-2.4 without problems.
I didn't have any issues before applying the patch and everything still seems fine with the patch.
Sorry, i'm not much help having not encountered the problem.
Comment #58
rodrigoaguileraMaybe it needs reassuring that the bug is still there, trying the steps in #35 or #44
There's 46 people subscribed, maybe it's not features fault.
I kinda apply the patch in every project like the monkeys in this experiment http://skeptics.stackexchange.com/questions/6828/was-the-experiment-with...
Comment #59
izmeez commented@rodrigoaguilera Thanks for the laugh :-)
Comment #60
kristiaanvandeneynde@rodrigoaguilera What are you trying to export? As I stated in #36, the problem is usually not with Features, but modules providing defaults incorrectly.
Comment #61
rodrigoaguileraOK
I stopped being a monkey and removed the patch. No feature is overriden.
Anyone is free to open it again with some steps to reproduce it.
Comment #62
izmeez commentedok, I'll also stop being a monkey see monkey do and remove the patch until the problem is clarified. :-))
Comment #63
grndlvl commentedDon't mind me still monkeying around "eek eek". Re-roll b/c it was easier than tracking down the culprit for this older project.