Originally mentioned in #614030-24: Cannot edit fields for taxonomy terms and now repeated in #742318: Fields are editable regardless of whether an bundle instance exists, missing menu titles, etc.:
The usage of the vocabulary id instead of the vocabulary's machine name in admin paths:
admin/structure/taxonomy/$vid[/...]
is a problem for Field UI (as fields are bound to bundle names, i.e. machine names), but also contributed modules who try to work with those administrative paths (f.e. admin_menu).
In general, the additional/historical vocabulary id in addition to a machine name seems superfluous, but at this stage, we can only fix those paths.
Comment | File | Size | Author |
---|---|---|---|
#24 | 744258-24.patch | 944 bytes | jpmckinney |
#23 | 744258-23.patch | 937 bytes | jpmckinney |
#22 | 744258-22.txt | 937 bytes | jpmckinney |
#15 | 744258-unique-key.patch | 922 bytes | catch |
#5 | drupal.taxonomy-admin-paths.5.patch | 14.92 KB | sun |
Comments
Comment #1
catchI think we should probably drop vocabulary ID in D8 - although note if we do that it means denormalizing the machine name to the taxonomy_term_data table - we'll need to check query efficiency since many, many taxonomy queries include vid.
It would be easy to add taxonomy_vocabulary_machine_name_load() as a wrapper around taxonomy_vocabulary_get_multiple() so that we can continue to use proper menu loaders on those paths. Is there any thing else to do there apart from updating some links?
Comment #2
sunRight, basically just those paths.
Comment #3
catchLooks great. Please wait for test bot before commit.
Comment #4
sunhah, I knew there'd be some hiccup. Not sure when I'll be able to get back to fix those, but feel free to beat me to it :)
Comment #5
sunFixed those tests.
Comment #6
yched CreditAttribution: yched commentedLooks good.
Comment #7
Dries CreditAttribution: Dries commentedI'm not sure I understand the problem this patch solves. The issue description is rather cryptic.
Comment #8
catch@Dries, all the background is in #742318: Fields are editable regardless of whether an bundle instance exists, missing menu titles, etc..
Comment #9
Dries CreditAttribution: Dries commentedI re-read #742318 but I still don't get it. Could be my jetlag.
Comment #10
sunThe current administrative menu paths for taxonomy are using:
$vid, however, is not the name of the bundle, to which fields are attached to.
Fields are attached to $vocabulary->machine_name in http://api.drupal.org/api/function/taxonomy_entity_info/7
In reality, the vid should have been removed when machine names for vocabularies were introduced. It's superfluous now.
Modules that want to do something with taxonomy bundles or fields, or integrate with those administrative menu paths for vocabularies need to do some ugly hick-hacks to translate back and forth the vid into machine_name and possibly back:
Comment #11
Dries CreditAttribution: Dries commentedBut the patch doesn't remove the ugly hick-hacks (love that term)? Would that be a follow-up patch? Right now, this patch adds more code than it removes.
Comment #12
sunoh, that code snippet I pasted above is from a contributed module, admin_menu. It merely outlines the problem of other modules with the current paths.
But yes, this patch is also a preparation for #742318: Fields are editable regardless of whether an bundle instance exists, missing menu titles, etc., which ultimately will revert the recently introduced changes of #614030: Cannot edit fields for taxonomy terms
Comment #13
Dries CreditAttribution: Dries commentedOK, that all makes sense now. Thanks for the various clarifications -- that helps. Committed.
Comment #14
moshe weitzman CreditAttribution: moshe weitzman commentedWhen you use our API, taxonomy_vocabulary_save(), there is no prevention of duplicate machine names. Nor is there any in the DB. I'm looking at several dupes right now, that I got just by installing same module few times.
We should at minimum add a UNIQUE index in the DB to match the assumption thats made here. At maximum, we add php checks when saving a vocab that the machine name is valid. Field API validates incoming data like this before it creates a field/instance.
Comment #15
catchHere's a patch to add the unique key.
The PHP check sounds good. We also likely need a safeguard when generated the machine names in the taxonomy update. I've not done either of those yet.
Comment #16
andypostReasonable follow-up
Comment #18
bcn CreditAttribution: bcn commentedCycling bot... patch should still apply.
Comment #19
catch#15: 744258-unique-key.patch queued for re-testing.
Comment #21
andypostHow could it break drupal install?
Comment #22
jpmckinney CreditAttribution: jpmckinney commentedI think you had the db_add_unique_key API wrong.
Comment #23
jpmckinney CreditAttribution: jpmckinney commentedRename it .patch so bot picks it up?
Comment #24
jpmckinney CreditAttribution: jpmckinney commentedFix array returned by hook_schema, too. Sorry for the triple-post.
Comment #25
andypostComment #26
andypostComment #27
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.
Comment #28
andypostSeems related #762604: Taxonomy terms list broken, term add/edit forgets it's parent
Comment #29
yched CreditAttribution: yched commentedHm, one nasty consequence is that is becomes difficult to know the vid of a given vocab...
Before this patch, I used to go to admin/structure/taxonomy and hover the links to get the vid from the URL. What other way do we have, other than looking in the db ?
Comment #30
moshe weitzman CreditAttribution: moshe weitzman commentedDevel module adds a tab to all term pages (and node/user/comment) where the full entity can be explored. I think thats sufficient.
Comment #32
YesCT CreditAttribution: YesCT commentedthis is the closest related issue to dealing with the vocab listing page I could find for #1891746: Make vocabulary label in administrative listing link to its list of terms. Is there a better issue more related I should link to?