The "list terms" item at admin/structure/taxonomy uses the vocabulary machine name for the path, but this causes a user to be directed to the taxonomy overview or add pages if the machine name and default menu arguments are the same.
To recreate:
1. Create a vocabulary named "List", allowing the machine name to default to "list".
2. Click the the "list terms" item at admin/structure/taxonomy.
Instead of being taken to the list terms page for the "list" vocabulary, you will stay on the overview page which is the default local task.
Likewise, creating a vocabulary with the machine name 'add', will take you to the add vocabulary page when the "list terms" path is accessed.
Adding "list" as a fourth argument in the path will display the correct page, but this breaks down on MENU_DEFAULT_LOCAL_TASK generated tabs (such as on the vocabulary edit page) .
The easy option is to disallow conflicting machine-names, which prevents having to change paths and menu items in the taxonomy module. I've included a patch that disallows "add" and "list" as machine-names for new vocabularies, though fixing the underlying issue would probably be a better approach if anyone has any input on how that might be accomplished.
| Comment | File | Size | Author |
|---|---|---|---|
| #31 | vocabularies-843162-31.patch | 2.52 KB | mtift |
| #29 | 843162-29.patch | 2.12 KB | a.mikheychik |
| #25 | 843162-25.patch | 2.07 KB | jhodgdon |
| #22 | 843162-taxonomy-vocab-paths-18.patch | 15.89 KB | berdir |
| #17 | 843162-taxonomy-vocab-paths-17.patch | 16.59 KB | scott falconer |
Comments
Comment #1
scott falconer commentedAttaching the patch.
Comment #2
jhodgdonWe need this.... subscribe
Comment #3
jhodgdonksenzee says anything you can bork through the UI is critical.
Comment #4
bleen commentedbased on this logic shouldn't we disallow "view" "edit" "feed" and (I think) "delete" also? I haven't tested this...
Powered by Dreditor.
Comment #5
bjaspan commentedre #3: I think the world of Katherine but I disagree with her on this point. "Anything you can bork through the UI is critical" is not a sensible rule. Is Drupal really useless unless this is fixed? It sounds to me like this can be addressed by saying "don't do that!" and then can be fixed post-7.0. So I suggest marking this normal priority.
http://acquia.com/drupal-7-get-real-get-dirty-get-it-done
Comment #6
pwolanin commentedLook - this kind of bug is why in places I changed the callback paths for things like managing content type and menus - without that, you have to create a path black list, which is always going to fail in some cases and is really a half-assed solution.
so - 2 possible solutions:
1) change the paths for the /add, etc
2) blacklist (as per the patch above).
Comment #7
jhodgdonSomeone already (unwisely) must have decided on these current paths in D7, because they are not the same in D6. I'm sure that changing the paths, although it's the right thing to do, would break all kinds of things by now. Sigh.
The blacklist idea is a total hack though.
Other places in core where there are menu router items that have this potential problem (i.e. machine names being used in router paths that could conflict with other paths):
- system_menu: 'admin/config/regional/date-time/types/%/delete' -- the % for type here is a machine name, and there is also 'admin/config/regional/date-time/types/add'
- shortcut_menu: 'admin/config/user-interface/shortcut/%shortcut_set' -- this is a shortcut set name, and there is also 'admin/config/user-interface/shortcut/add-set' and several with ../shortcut/link/* etc.
I personally think we should fix the paths, although it will be painful at this point.
Comment #8
pwolanin commentedChanging paths is not that painful - needs to be done asap.
Comment #9
pwolanin commentedFixed the tests.
Comment #10
pwolanin commentedoops - bad diff
Comment #12
jhodgdonWhat about the other spots with the same problem in #7?
Comment #13
scott falconer commentedHere's a patch with updated tests for the path change.
Comment #14
scott falconer commentedUpdating status to needs review.
Comment #16
jhodgdonLooks like there are still 4 tests failing due to bad paths.
Also, the other spots mentioned in #7 have not been addressed...
Comment #17
scott falconer commentedIncluded patch changes the path change from taxonomy-vocabulary to taxonomy/vocabulary. This is more in line with how content types work, keeps the breadcrumbs intact, and fixes the underlying "List" and "Add" name conflict. In a few places, references to argument 3 needed to be changed to 4. I could see this possibly causing some problems with contrib. modules that look to the path arguments to load the vocabulary name, but it should be an easy fix in those cases.
As per the questions in #7, I've checked the paths:
- system_menu: 'admin/config/regional/date-time/types/%/delete' -- the % for type here is a machine name, and there is also 'admin/config/regional/date-time/types/add'
Tested with type names 'add' and 'delete'. No issues.
- shortcut_menu: 'admin/config/user-interface/shortcut/%shortcut_set' -- this is a shortcut set name, and there is also 'admin/config/user-interface/shortcut/add-set' and several with ../shortcut/link/* etc.
Tested with type names 'add-set', 'add' and 'list'. No issues.
A few other places like 'admin/structure/types' use machine names in paths without issue, but it might be a good idea to write a general test that checks path arguments as machine names just to be sure.
Comment #18
jhodgdonThanks for testing...
- Agreed on the date-time paths -- I couldn't make it break either.
- On the shortcut sets, it appears that the machine name of shortcut sets is defined by the shortcut module to be shortcut-set-1, shortcut-set-2, etc. So the name you choose for the shortcut set cannot affect the path adversely.
Comment #19
pwolanin commentedFor D7 I guess we allowed an extra level or two for router items - so these paths will work, though note that that there is some potential performance penalty for longer paths.
Comment #20
sun.core commented#17: 843162-taxonomy-vocab-paths-17.patch queued for re-testing.
Comment #22
berdirSimple re-roll of the patch. Only had a single failed hunk in taxonoy.admin.inc.
I'm however wondering if this isn't an API break.. userpoints.module for example contains a link to the vocabulary page which it has defined and this patch is going to break that I think :)
Comment #23
jhodgdonYes, I imagine it is too late to fix this in Drupal 7 by changing the paths.
We could conceivably "fix" this by not allowing people to save vocabularies whose machine names are "list" or "add".
Comment #24
scott falconer commentedPatch #1 prevents vocabularies with machine names "list" or "add", but as others have mentioned we'd need to make sure we're blocking all problem names.
The other options I see are:
Modify problem machine names to something like "list_0".
Treat 'list' and 'add' as machine-names that are already is use and follow the same steps that occur if a user tries to create two vocabularies with duplicate machine-names.
Comment #25
jhodgdonBack to the idea of patch #1 then....
I took a look at taxonomy_menu(), and I'm quite certain that 'list' and 'add' are the only problematic vocabulary names.
So the ideas that have been proposed to solve this problem this are:
- Patch #1 - in validation for the vocabulary add/edit form, throw a form error if the machine name is 'list' or 'add'
- Patch #22 and others - changing paths - bad at this stage of D7
- Treat 'list' and 'add' as machine names that are in use and do whatever they do - I think this would be bad from a UI perspective, because the user will not understand what it means. For instance, they create their first vocabulary and happen to call it List, and it says "machine name list is already in use" or some such error message - that would be confusing.
- Modify machine names automatically - I also think this is not a good idea. We should let the user deal with the problem, not guess at a solution.
The problem is, the patch in #1 will not apply, because the form validate function that it was modifying no longer exists. The validation is now happening only in form_validate_machine_name(), which is calling taxonomy_vocabulary_machine_name_load() in order to verify that the machine name doesn't already exist.
So instead what we'd need to do is add an additional #validate to the form, and put in those 5 lines from patch #1.
Here's a patch. It works for me on my test box - prevents adding 'list' or 'add' machine names, but doesn't prevent anything else. Sorry, I couldn't resist also bringing the docblocks up to standards, since I needed to put some @see lines in there... hope that's OK.
Comment #26
berdirI'm wondering if this is something that we might want to add to the generic machine_name validate function? I guess there are more forms with machine_names which need a similiar validation, I myself have a module that does...
Looking at #902644: Machine names are too hard to implement. Date types and menu names are not validated, there are several #machine_name_something properties that allow to fine-tune the validation and other things. Theoretically, I guess it would be possible to do this through the regular expression but that is quite complicated. Maybe we could add something like this:
Also..
I don't think that we can add new strings at this point, string-freeze and so. Obviously it would be better UX than a generic "This machine name is not valid" error message but I guess we'll have to live with that...
I can create a patch, just wanted to ask for feedback before doing that...
Comment #28
jhodgdonI don't think there is an existing string error message that will do. Take a look at http://api.drupal.org/api/drupal/includes--form.inc/function/form_valida... -- you will see that all the messages there are quite specific. So the choices will be to use a message that is misleading/incorrect, ot to add a new string.
I do like your idea of adding a name blacklist to the machine name element as a better way to solve this.
And I'm not sure why the test failed. The function works just fine on my test machine.
Comment #29
a.mikheychik commentedSmall update of patch: we should check is the machine name key is set, because this validation also passing during deletion, that's wy test crashes with Notice
Comment #30
jhodgdon+1 on this patch. Doc is good anyway.
Comment #31
mtiftPrevious patch failed. Re-rolled patch from root to fix file paths.
Comment #32
Dave.Ingram commentedApplied patches, ran tests, and tested all the validation functionality of the patch. Looks ready to go!
Comment #33
jhodgdonNeeds to go to d8 and then d7
Comment #34
catchtagging for backport.
Comment #35
dries commentedI'm willing to commit this patch in order to make progress with 7.x and 8.x. However, I'm not sure this is the most elegant fix for 8.x. Once we get this in in 7.x and 8.x as a stop gap solution, should we try to resurrect http://drupal.org/node/843162#comment-3912612 for D8? I'm recommending that we do.
Comment #36
dwwNote to anyone that lands here looking at the Git commit history for the Update manager. Dries accidentally committed the fix for #1008328: Uniqueify update-cache and update-extraction directories to prevent "Permission denied" errors as http://drupalcode.org/project/drupal.git/commit/02dd3c5 which said:
Just leaving a pointer in case anyone ever tries to sort out the Git archeology and is wondering WTF happened... ;)
Cheers,
-Derek
Comment #37
jhodgdonRE #35 - agreed, for d8 we should eventually change the paths like the patch in #22 above. But probably not for D7.
Comment #38
dries commentedCommitted this patch to 7.x and 8.x. I'm changing the status field to 'needs work' and lowering the priority so we can discuss code clean-ups for 8.x.
Comment #39
berdirSetting status to needs work (or should it be active? not sure..)
Comment #40
andypostIs this a good issue to change a router paths all over core? suppose we should start new one and change all menus to format:
.../[module-entity]/[action]/[machine name and other parameters]
Also this could not be backported to D7 because of contrib modules that already use current paths.
Comment #41
jhodgdonI think if you want to change router paths all over core (again -- there were a LOT of changes for D7 too), it should be a separate issue.
Comment #42
andypostRelated issue #1552396: Convert vocabularies into configuration
Comment #43
andypostSuppose it's now obsolete after #1978112: Convert taxonomy admin path to follow other core entity patterns
Comment #44
andypostD8 uses common pattern for path after #1978112: Convert taxonomy admin path to follow other core entity patterns