Closed (fixed)
Project:
Features
Version:
6.x-1.0-beta6
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
15 Jan 2010 at 23:05 UTC
Updated:
4 Jun 2010 at 23:10 UTC
Jump to comment: Most recent file
Comments
Comment #1
john.karahalis commentedWe can confirm this behavior.
If one CCK field is used by two different content types, any Features using that field will be listed as "Overridden" immediately after being enabled. We also noticed a problem with help text. If a field was originally used in two different places with two different help texts, only one help text will be used in both places after the field is wrapped into a Feature.
By the way, great work with the module (and with Managing News, and Open Atrium, and all the other amazing stuff you do :-)).
Comment #2
m_z commentedI can provide some simple code (for the maintainers of the Features module) to switch between different cases when adding a CCK field via Features module.
The code is a modification of different code that I found at Drupal.org. I used the code for my own "CCK-definitions-in-code"-import module, but Features module is much better!!!
Maybe this can be a starting point to solve this issue:
Comment #3
hadsie commentedI'm running into this same issue. It looks like the field settings are being written properly to the feature. They're all set as the should be when i check defaults.inc. For some reason they just aren't getting re-imported into the system properly.
Also, for the field order issue, I submitted a patch for it here that seems to be working for me so far: #693944: Add strongarm integration in features.content.inc for 'content_extra_weights_[typename]' variable
Comment #4
m_z commentedDoes anybody know how CCK fields are "imported" by Features module?
Do they a) live in code (at runtime) or is there b) a physical import into the database.
I don't have the time to dive into Features module's code, but I think that b) is the right answer.
Then the next question would be: Does Features module use some API functions of Content (CCK) module or are there own CCK import functions in Features module.
To solve this issue we must find the place where the switch (see #2) must be included...
(and maybe we need some additional code to handle the case "Add existing CCK field to content type.")
Comment #5
yhahn commentedI won't be looking deeply into this anytime soon but I can certainly answer these questions if someone wants to explore the issue further and jot some notes down (or work a patch to fix it).
CCK fields are indeed imported into the DB as they are not true exportables. Features uses the CCK API functions (OTOH content_field_instance_create() and content_field_instante_update()) in includes/features.content.inc.
Comment #6
m_z commentedThanks yhahn!
In my own approach I use drupal_execute() to create my CCK fields from my CCK field settings code (it differs a little bit from what you get by using CCK export functionality).
Going this way I get the wanted behaviour that there is no difference between the creation of a CCK field manually (via UI) and the creation of a CCK field with my own import logic.
Especially the case "existing CCK field for a new content type" (which is causing the trouble in Features module) works well with my approach.
Do we have a CCK expert here who is familar with CCK API functions? I don't have the time to become such a CCK expert right now...
Like said before: I like Features module and I am interestend in a working CCK import inside Features module.
Comment #7
joachim commentedI'm seeing a problem with the same field on different types -- if one type is then removed, parts of CCK still think the field is using the multivalued storage system, and subsequent node save operations fail.
Comment #8
m_z commentedWhere is our CCK guru to solve this issue?
A starting point for some research could be 'Manage fields' form at content type settings (admin UI): http://drupalcontrib.org/api/function/content_field_overview_form/6
I think that comparing the 'manual way' of CCK field creation (or update) via admin UI with the 'automated way' in Features module is the key to find a solution.
The relevant function inside Features module should be: http://drupalcontrib.org/api/function/content_features_rebuild/6
Right?
And this is the code that I used as basis for my own CCK import functionality (which is working fine, but I like Features module UI...)
http://drupalcontrib.org/api/drupal/contributions--install_profile_api--...
There is a
content_field_edit_form_submit(http://drupalcontrib.org/api/function/content_field_edit_form_submit/6) call at the end ofinstall_create_fieldfunction which is not included incontent_features_rebuildfunction inside Features module (see above). Could this be the reason???Enough for today. Maybe someone helps me, diving into this issue...
Comment #9
David Stosik commentedHello,
I think I spotted a possible origin for this issue.
See function content_field_instance_create() in content.crud.inc ?
If a prior instance of the field is already existing, then this function sets $field['widget']['weight'] (and label and description) to the value inside $form_values, or, if it is not set, to the value of the previous instance. Hence, the first imported field instance gets the right weight, but the following instances of the same field get the first's weight instead of their own weight.
What I suggest is, in features.content.inc, before calling content_field_instance_create(), set the weight, label and description at the field level, because content_field_instance_create() will use them as the $form_values.
Please find my suggested patch attached.
Regards,
David
Comment #10
sdelbosc commentedJust to track the issue...
Comment #11
jonskulski commentedsubscribing.
Comment #12
m_z commented@David:
Thank you for your patch.
I will test it in the next days and report back here...
Comment #13
D.H. commentedThanks for the patch. I used an image field on two cck types and changed the order and also the label names and it seems to work properly.
Comment #14
m_z commentedFor me it seems to work properly, too. Changed status to rtbc.
@David: Thanks again.
Comment #15
jonhattanthanks. It works here also.
---
and drush make is awsome :)
Comment #16
yhahn commentedThanks: http://drupal.org/cvs?commit=370120
Update your makefiles : )