I only have 1 vocabulary activated for TM.
I should find no traces of TM when manipulating other vocabularies, however:
- when I create and add a new vocabulary, (without TM activated on that vocabulary), the message 'The Taxonomy Menu has been removed.' comes up.
- when I check the variables table (e.g., with page devel/variable) This is filled with all vacab's not only the activated.
IMO, this is confusing, and makes me curious if the module processes too many code at other moments, too (CRUD on terms, CRUD on Vocab's).
This happens in function taxonomy_menu_vocab_submit(). It should be sanitized.
IMO, when saving the vocabulary settings,
- if 'Menu location' is and was empty, the function should do nothing;
- if 'Menu location' is unset, the menu items must be rebuilt(deleted) and the variables can be deleted (but can be kept, too.)
- if 'Menu location' is changed, the menu items must be rebuilt and the variables must be set.
- if an option is not set, no variable should be set either.
(When any of the settings was set before, you may set and keep it.)
Comments
Comment #1
johnvOops, wrong version.
Comment #2
johnvSee attached patch.
I left an indent, for better readability of the patch.
P.S. we might want to create an update function to remove cleans the variables table.
Comment #4
hles commentedThis is great that you spend some time working on Taxonomy Menu Johnv. But unfortunately this kind of patch will unlikely make it in the 1.x version. We already use our free time (which is not a lot) to integrate missing features into 2.x and polish it, which btw already takes care more or less of this issue. Don't get me wrong, this is great, but that would be some much greater if you could provide this kind of patch for the 2.x version instead ! :)
Comment #5
johnvI am happy to create a patch for the version you like.
Indeed, I am confused about the status of version 1 and 2.
Am I correct: Version 1 is now stable, and all developing effort goes to version 2?
Comment #6
hles commented1.4 is stable, 2.x was created to handle internationalization at first but it ended up heavily modified, a lot of tests were added to make sure things are working correctly, which is not the case in 1.x. Also, all new features are now written against 2.x and won't be backported to 1.x. This is also a problem of maintainers being very busy and not having the time to maintain 6.x, 7.x-1.x and 7.x-2.x at the same time.
Comment #7
johnvI understand. Putting this info on the project page will be helpful. Thanks!
Comment #8
johnvAttached patch is updated for 2.x , and does the following in the submit callback:
- do not touch vocab's that are not activated for TM.
- do not save the 'rebuild menu' setting. This is a one-time action.
- moving between parents was not captured.
Comment #9
hles commentedThese changes make sense to me. It would be nice to reflect these changes in the functional tests. Should be pretty straight forward. But overall that looks good to me.
There is one thing I don't feel right is that we need insert and update flags to TRUE at the same time ?
Comment #10
hles commentedTagging accordingly.
Comment #11
johnvAttached patch addresses your remark #9.
It also makes the fist lines of the function a bit more readable.
IMO, the value 'vocab_parent' can be used and stored as a variable unchanged. ATM it is normalized and deconstructed into parent and menu, and 2 variables are saved. The use of the second variable 'vocab_menu' seems superfluous.
This might need an update-function, but can also be done with a variable_del() upon saving.
It is not applied in this patch - need your opinion first, and can be addressed in a follow-up issue.
Comment #13
johnv#11: taxonomy_menu_1896916_11_submit_settings.patch queued for re-testing.
Comment #15
johnv#8: taxonomy_menu_1896916_8_submit_settings.patch queued for re-testing.
Comment #16
johnvLast patch did not save the settings in all cases.
Comment #17
hles commentedThis seems clean to me and almost ready for a commit. Don't forget to merge with the latest dev, 2 commits have been added since your last patch.
Maybe these rebuild_needed could be set after the if/elseif statement but this is really minor.
Comment #18
hles commentedChanging status just for the reroll against latest dev.
Comment #19
johnvCan you give your opinion on my #11 suggestion? IMO it simplifies the code.
Comment #20
hles commentedBoth solutions would work, but I'm not sure why it would simplify the code. What you are saying is that we should save "main-menu:123" value (for ex) instead of both "main-menu" and "123" ?
Comment #21
johnvIndeed,
there is no point in separating the values before storing, and re-assemble them before re-use. Just save the variable taxonomy_menu__parent = "main-menu:123" .
For not-active vocabs, it would be taxonomy_menu__parent = "0" IIRC.
But there is no need anymore to normalize, reassemble and destruct: just save, compare the submitted value with the old value, or compare the submitted value with '0'.
Comment #22
hles commentedI see what you mean for the admin part. But wouldn't we have to deconstruct the variable each time when "parent" or "menu" is used elsewhere in the module ?
Comment #23
johnvI have checked that: It is not used anywhere, but I will check again.(how else would you know where to append the menu items?).
[EDIT] both variables are used in several places. Let's leave it like it is.
Comment #24
johnvTesting the 'assigned' feature.
Comment #25
johnvAttached patch moves the 'menu_rebuild_needed', as you stated.
I also discovered that a menu disable/remove is the same as a rebuild, and changed the code accordingly.
Comment #26
johnvEven shorter and more explicit.
Comment #27
hles commentedI'll commit this when I have time.
Comment #28
hles commentedRe-reading the code, I found the following:
The comment is not correct, if the menu has moved, then we need an update, not a rebuild.
We need to insert menu links only if the previous menu location was "NONE/DISABLED". Which is already done in the first condition above I think. I'm pretty sure we can remove this condition.
These use cases should be added in testTaxonomyMenuVocabularyInterface so we don't have to wonder about this logic (mostly menu changes) later. Moreover this is just a matter of few lines in the tests.
Comment #29
johnvIn attached patch:
- I removed the mentioned comments - code speaks for itself.
- I moved variable_set('menu_rebuild_needed', TRUE); back to the last line. This was OK in the original code.
THis line needs to be there, otherwise there is no menu update. Since I might have understood you incorrectly, I tried switching taxonomy_menu_menu_links_insert() vs. taxonomy_menu_menu_links_update() . Both work equally fine, where _update() seems a bit faster. I did not change that line of code, since it is not the scope of the patch.
However, it seems both function effectively do the same thing, in a slightly differfent way. IMO one of both can be discarded, but I may miss some fineprint.
I cannot help you with automated tests. I did not encounter a project big enough to invest in that (valuable) feature.
Comment #30
hles commentedYes I think both functions do the same thing, we will need to clarify that better in another issue.
I'll provide the tests whenever I can find some free time, if nobody does, and commit this very patch. I'm sorry not being able to be more reactive on this, but there are just too many things I have to do right now.
Comment #31
Anonymous (not verified) commented#11: taxonomy_menu_1896916_11_submit_settings.patch queued for re-testing.
Comment #31.0
Anonymous (not verified) commentedbetter explanation.
Comment #32
jenlamptonLooks like this needs a reroll, there is no taxonomy_menu.admin.inc anymore.
edit: I updated the patch so it would affect the .module instead, but the patch still failed. Additionally, it doesn't look like there is a function
_taxonomy_menu_flatten_form_settingsanymore, so this will likely need more than just a reroll.Comment #33
jenlamptonI'm attaching a new simplified patch that solves the problem of the 'The Taxonomy Menu has been removed.' message appearing for new vocabs.
Comment #35
jenlamptonthis one should pass tests.
Comment #36
jenlamptonOh, the correct branch will help.
Comment #38
jenlamptontrying to get testing working - uploading patch from #35 again.
Comment #39
jenlamptonstatus
Comment #40
vladimirausThank you for your contributions.
Drupal 7 is no longer supported.
Closing this issue as outdated.