Closed (fixed)
Project:
Features
Version:
7.x-2.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
27 Jan 2011 at 13:35 UTC
Updated:
16 Oct 2013 at 14:40 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
gram.steve commentedJust curious, but does your module implement its own hook_node_info()?
I am having a similar problem with features when the base module implements this hook and the responsible module for that content type is mine (so features does not implement its own hook_node_info() in hook.features.inc ). Features keeps the node component as FALSE in its
"normal" settings, then compares that to the output of hook_node_info() "default", which are not the same.
These feature modules (there are three like this) always show overriden.
The problem seems to be in features.export.inc, in the function features_detect_overrides(). In my copy this appears to be happening at line 288:
In the case of the node component, there should probably be an exception here.
Steve
Comment #2
gram.steve commentedBumping this to bug report on component code
Comment #3
gram.steve commentedAttaching a suggested solution (as a patch against ver 6.x-1.0) as a patch file. It seems to be working for me as it should now.
Comment #4
gram.steve commentedSorry, left some testing code in the last patch, adding another one without the testing code.
Comment #5
gram.steve commentedChanging status to get this patch reviewed
Comment #6
pcarman commentedfollowing
Comment #7
stephenrobinson commentedme too
Comment #8
Anonymous (not verified) commentedHi
I am creating a new custom module using features module. First I have created a new module by interface i.e, In admin, features, Create features. Now I want some changes in the module created to do the same, again I go to interface made the corresponding changes than recreating the module using features >> recreate.
Now I got some files, and uploaded it to the server i.e, the latest files. Now if I am going to features the status displays as Overridden. Once I will click on the same it shows me the list with check box for an option lets say infronnt of taxonomy. If I will check this box and save this the status of the features changed to "Default".
I want to know that is it fine. Is this the way to do this or we should keep the module status as overridden. Now If we will keep the status we are not finding the changes that we made.
Please suggest.
Comment #9
hefox commentedTrying to clarify the title; there's a few similar issues.
From a brief look, this is not specific to node (on a seperate note, node specific stuff should not be in features.export [please patch against -dev if can].); the issue is that if you remove an item from an export, then add it back in via a non-features controlled hook and change it, features does not realize that that item is not part of the current feature, correct? If so, Ttat should be fixed generally.
Please try and avoid code style fixes (the spacing fixes) as they're a separate issue altogether.
Comment #10
phayes commentedThe problem doesn't have anything to do with the cache, but rather in how features_get_default detects wether a hook has been implemented.
features_get_default blindly checks to see if a hook has been implemented (such as hook_node_info) by checking to see if the function exists, without actually checking where the hook was defined. It assumes that if the hook has been defined, then features is responsible for it! This means that features will mark as overriden any module that implements a hook that a component also implements, even if said component is not part of the feature.
I think we should be able to fix this by checking the file in which the function was defined and see if it matches the file where features expects to find it.
Comment #11
phayes commentedAlso updating to the latest dev since this should be fixed here first then backported.
Comment #12
phayes commentedSo I've dug into this a bit more and dealing with this at the level of features_get_default won't be possible. PHP provides no easy way to determine *where* a given function is defined. The only way to to this is to file_get_contents and grep the file for the function definition. Yuk. I tried this anyways and doing this resulted in timeouts. :-(
So there is no way to fix this bug at it's root until PHP provides a way to determine where a function has been defined. We need to fix it one level up in features_get_component_states.
Will post more details shortly.
Comment #13
phayes commentedSo I've given up. This needs the attention of someone who knows how features works at a more intimate level. For those who just want this problem to go away, here's some code you can drop in at the beginnings of your hooks that features is erroneously detecting.
Comment #14
hefox commentedfeautures knows what component it currently handles for a module based on the .info features array, so it should be checking if it actually handles that component before calling information on it, at least as far as override detection goes.
Comment #15
phayes commentedHi @hefox,
That's what I thought would happen, but does not appear to actually be the case. If you would like I can create a simple feature the demonstrates this problem and paste it here.
Comment #16
phayes commentedAttached is an example of a bad module that has this bug.
The module part defines the content-type using hook_node_info, and the feature defines a field. The feature is overridden and cannot be reverted.
Comment #17
hefox commentedThis patch was done against 6.x, so not updating to needs review. It should be easily adapted to d7 as the code isn't that much different.
Comment #18
mpotter commentedHere is a version rolled on the latest 7.x-dev. The first time I cleared cache after installing it I got errors around the foreach in features.export.inc complaining that the $all_features[$feature]->components was not an array for array_intersect. But after that initial error, subsequent cache clears were ok and I didn't encounter any problems. So might just need another isset() or is_array(). Marking this for review.
Comment #19
blackice2999 commentedHi mpotter,
your last patch #18 seems also fix #1721926: Field Instance Export "weight" - brings me in a Override ping/pong - quotes and no quotes
Comment #20
mpotter commentedHere is a slight variation of the patch from #18 that also fixed the error when clearing cache the first time.
Really need to get some eyes on this to see if it has any other side effects.
(note this probably doesn't really "fix" anything in 1721926, it just potentially removes an overridden difference in a feature that might make it look that way)
Comment #21
mpotter commentedHmm, is this still an issue? Let's run the automated tester.
Comment #22
mpotter commentedComment #24
barrapontoreroll
Comment #25
mattsmith3 commentedThis is quite lovely. Thanks for the work here!
Comment #26
mpotter commentedCommitted to f87d486.