See the API: http://api.drupal.org/api/function/taxonomy_field_info/7
Taxonomy term reference field allowed values is an array of trees or subtrees. When the 'parent' is 0, it means to use the whole vocabulary. The 'vid' setting would ideally be the vocabulary's machine name. Or not? Please advise.
Comment | File | Size | Author |
---|---|---|---|
#23 | 881530_vocabulary_field_machine_names.6.patch | 10.41 KB | yhahn |
#19 | 881530_vocabulary_field_machine_names.5.patch | 9.7 KB | yhahn |
#15 | 881530_vocabulary_field_machine_names.4.patch | 8.09 KB | yhahn |
#11 | 881530_vocabulary_field_machine_names.3.patch | 8.25 KB | yhahn |
#8 | 881530_vocabulary_field_machine_names.2.patch | 6.49 KB | yhahn |
Comments
Comment #1
yched CreditAttribution: yched commentedIndeed, that's an oversight. As is, the much-awaited introduction of vocab_machine_name doesn't bring any actual progress in terms of exportability (well, the initial reason for the introduction of vocab_machine_name was not exportability but simply to provide 'bundles' in order for terms to be fieldable - but it would be a shame to not take the exportability benefits that come along).
Thus, raising to 'major'.
Although : vocab machine name is editable and thus can change over time. When it does, we need to update all existing $field definitions and change machine names accordingly.
Comment #2
yched CreditAttribution: yched commentedLess techie (?) title
Comment #3
fagoSubscribing.
Comment #4
yhahn CreditAttribution: yhahn commentedThe following patch switches the reference of taxonomy term reference fields to use the vocabulary
machine_name
rather than vid. The effectiveness of this patch for exporting term reference fields and vocabularies has been tested using Features 7.x.Comment #5
yhahn CreditAttribution: yhahn commentedComment #6
andypostSuppose 'forum' module should be fixed too...
Comment #8
yhahn CreditAttribution: yhahn commentedUpdated patch fixes Forum module field creation. 16 assertions (breadcrumb related) fail locally in the forum module tests with or without the patch.
Comment #9
Anonymous (not verified) CreditAttribution: Anonymous commentedThanks for picking this up yhahn.
Unfortunately, my Dreditor is broken, so we'll just have to do it in Drupal 6 fashion.
Is 0 appropriate? It's never a valid machine name. It's probably fine, but I suspect this value is the original value for that setting for new fields.
The comment on taxonomy_field_info() needs to be updated to reflect the change from vid to vocabulary machine name.
Will this need an update hook? Or is this something for head2head to deal with?
Comment #10
sunI agree, the default should be an empty string.
We can put the first line into the condition here.
I wonder why this is still based/keyed by vid? It would make more sense to consistently use the vocabulary machine name.
I wonder whether we cannot simply drop the entire 'vid' line? A machine name should be sufficient to store a term -- it's even "more unique" than the vid after all.
Powered by Dreditor.
Comment #11
yhahn CreditAttribution: yhahn commentedLatest version.
hook_field_info()
$terms = taxonomy_get_tree(...)
moved intoif()
taxonomy.install
for updating field definitions from old to new formatThe latter instances of
vid
that sun notes are necessary as they are used to load and return term objects. Term objects still need to be loaded using vid when using a condition withtaxonomy_term_load_multiple()
as{taxonomy_term_data}
references vocabularies by vid. I think it is fine to use vid for internal/joining usage but in stored settings and external API calls moving to using the vocab machine name will be best.Comment #13
yched CreditAttribution: yched commentedThanks yhahn for tackling this.
The update function belongs in head2head rather than core. The current D6->D7 update func that creates taxo fields from D6 vocabs should probably be amended though ?
Comment #14
moshe weitzman CreditAttribution: moshe weitzman commentedAwesome to see work on this. Subscribe.
Comment #15
yhahn CreditAttribution: yhahn commentedv4:
machine_name
Comment #17
Anonymous (not verified) CreditAttribution: Anonymous commented#15: 881530_vocabulary_field_machine_names.4.patch queued for re-testing.
Comment #19
yhahn CreditAttribution: yhahn commentedUpdated, fixes upgrade path test.
Comment #21
yhahn CreditAttribution: yhahn commented#19: 881530_vocabulary_field_machine_names.5.patch queued for re-testing.
Comment #23
yhahn CreditAttribution: yhahn commentedFound one more spot that needed fixing.
Comment #24
arianek CreditAttribution: arianek commentedsubscribe
Comment #25
chrisshattuck CreditAttribution: chrisshattuck commentedI may not be the best one to review this patch, but from what I can tell it looks good. I haven't had a chance to run the patch myself, but I'd really like to see the machine names leveraged for real exportables in core wherever we can.
Comment #26
jhedstromsubscribing
Comment #27
eaton CreditAttribution: eaton commentedI just took this through its paces, from running the tests to poking through the UX to experimenting with a bit of sample code to create and manipulate vocabularies. The code changes are simple and straightforward, and the fix facilitates a really, really essential part of D7's deployability. Big +1 to the patch.
Comment #28
Anonymous (not verified) CreditAttribution: Anonymous commentedThanks Eaton for testing it so thoroughly. I concur on RTBC.
Comment #29
webchickI think this patch makes sense.
Machine names for vocabulary names went in a long time ago, with the expectation that they'd work for feature exportability. This patch fixes it so it does. If it broke anything too badly, our tests should be screaming now.
Committed to HEAD. Thanks!
Comment #30
alex_b CreditAttribution: alex_b commentedw00t! :)
Comment #31
catchThis should be documented as an API change (for any modules or install profiles that create term reference fields).
Added a head2head issue - http://drupal.org/node/928278
Comment #32
irakli CreditAttribution: irakli commented+1 w00t!
Comment #33
yched CreditAttribution: yched commentedyay, thx yhahn !
@catch #31 : D7/D7 API changes are usually advertised on the dev mailing list, not on the D6/D7 migration page per se.
http://drupal.org/node/224333 did contain some sample code that needed to be updated accordingly, I just fixed that - see
http://drupal.org/node/224333/revisions/view/1179662/1181260 for the changes.
Anything else before turning back to 'fixed' ?
Comment #34
yched CreditAttribution: yched commentedSee also #876762: Modules have no way of knowing if vocabulary machine names are changed for another important block on the road to vocab exportability.
Comment #35
catchyhahn posted a head2head issue which I committed, that plus the docs changes seems fine to me, moving back to fixed.
Comment #36
catchComment #37
rfayOK, so please explain the API change to me :-) Thanks.
Comment #38
catchThe API change is this:
1. Any module or install profile using field_create_field() to create a term reference field will need to specify a vocabulary machine name for allowed values instead of $vid.
2. (just found this out when merging in head for ex2), any term reference validation handlers or other contrib or custom widget code which checks allowed values will need to change from $vid to machine name too.