The current implementation tries to pass the old taxonomy terms in comment_alter_taxonomy_original_taxonomy in order to preserve non alterable vocabularies during taxonomy_node_save.
This refactoring output all taxonomy widgets and simply disable (ie. transform the widgets to 'value') those which are not alterable by the current user.
This way, both _comment_alter_taxonomy_taxonomy_form_parse,comment_alter_taxonomy_validate and _comment_alter_taxonomy_all_taxonomy can go.
Also, _comment_alter_taxonomy_save_tids can directly get data from the database, because comment_alter_taxonomy has an heavier weight than taxonomy.
Refactored several other code (using isset() instead of the slow array_key_exists() in several places).
Also fixes #223073: Comments by users without proper permissions can change terms.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | comment-alter-taxonomy-refactor-8.patch | 27.99 KB | aclight |
| #9 | comment-alter-taxonomy-refactor-7.patch | 26.95 KB | aclight |
| #7 | comment-alter-taxonomy-refactor-6.patch | 26.95 KB | aclight |
| #6 | comment-alter-taxonomy-refactor-5.patch | 25.23 KB | aclight |
| #5 | comment-alter-taxonomy-refactor-5.patch | 25.18 KB | damien tournoud |
Comments
Comment #1
damien tournoud commentedComment #2
damien tournoud commentedA user that don't have access to alter taxonomies could get a fieldset in some cases.
Comment #3
damien tournoud commentedThis should solve some strange behavior with users' permission.
Comment #4
damien tournoud commentedAlso add a fake term to prevent _comment_alter_taxonomy_save_tids to be called as long as the node has no term.
Comment #5
damien tournoud commentedSilly parse error.
Comment #6
aclight commentedReroll to fix a typo in line 300
Comment #7
aclight commentedHere's some cleanup and increased documentation.
There's still one problem with this patch. I haven't worked out the exact problem, but basically what I did was I had several vocabs that were for issues, but I had the cat module disabled. I created an issue and assigned some terms to it.
I then enabled the module, but didn't have any of the vocabularies enabled for cat. I then followed up to the issue. Then I enabled cat for one of the vocabularies for issues, then created a comment and changed the value of one of the terms.
I got some db errors:
I have to head out now and will try to finish reviewing the patch tonight, if I have time.
Thanks for working on this so much, it will be a great improvement.
Comment #8
damien tournoud commentedYou removed the
0, 1at the end of that line, which brakes the thing and leads to the behavior you described.Comment #9
aclight commentedYep, you're right. Attached patch fixes this.
Another problem I noticed.
Disable cat. Create a new issue, and assign some terms to it.
Create 2 or 3 comments on this issue.
Enable cat, but don't enable cat for any vocabularies.
Create another follow up on the issue.
Enable cat for all the vocabularies you used in the first step.
When you view the issue, the terms appear to have been removed in the first comment, and then added back later on, even though in reality you only assigned the terms on the original issue node.
Comment #10
aclight commentedHere's the most recent patch with a few more corrections and comment changes.
Comment #11
aclight commentedFixed with http://drupal.org/cvs?commit=143033 (patch in comment #10).
I've opened a separate issue for the bug I describe in comment #9 at #314260: Strange behavior when comment_alter_taxonomy module is enabled after node is already created since that'll make it easier to review the fix for that bug.
Thanks a lot for writing this patch. It simplifies the form quite a lot.
Comment #12
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.