API page: https://api.drupal.org/api/drupal/modules%21taxonomy%21taxonomy.module/f...
Enter a descriptive title (above) relating to function taxonomy_vocabulary_delete, then describe the problem you have found:
From a quick read of the code, this function does quite a bit of housekeeping. This may either be a good or a bad thing depending on what you're after!
- all terms in the vocab are deleted
- // Load all Taxonomy module fields and delete those which use only this
// vocabulary.
Comments
Comment #1
jhodgdonWell... that seems like necessary housekeeping that would be implied if you delete a vocabulary, but sure we could document it.
Comment #2
joachim commented> that seems like necessary housekeeping that would be implied if you delete a vocabulary
Depends how well you know Drupal... deleting a node type doesn't delete any nodes, for instance.
Comment #3
jhodgdonGood point. Patch?
Comment #4
izus commentedhi,
i suggest following patch.
Thanks
Comment #5
jhodgdonLooks like the patch documents what it should... However, there's a spelling error in the first line: "vocabulay". Whoops! :)
Also, looking at the code for this function, it appears that it first updates all Taxonomy fields so that they don't reference the deleted vocabulary, and then completely removes fields that have no referenced vocabularies left.
I'm also circling back to wondering how essential it is to document this anyway. The same code is executed in Drupal 8 on Vocabulary::preDelete() [that does the term deletes] and Vocabulary::postDelete() [that takes care of the fields]. If it needs to be documented in 7, then it probably needs to be documented in 8; whether it really needs to be documented at all is a question, but moving to 8.x for action because we have a policy of fixing bugs in 8 first and then 7.
I'd really be inclined to mark this "won't fix" or "works as designed" though, as I suggested in #1.
Comment #6
joachim commentedThese are API functions that are intended for general use, therefore I think they should describe what they do.
Comment #7
izus commentedHi,
here are suggested patches for D8 and D7
Thanks
Comment #10
izus commentedoups !
i forget to mention do-not-test for the D7 patch
Comment #11
jhodgdonHm. OK, let's after all just do this for 7, if we're doing it at all.The argument about needing to do this only applies to the 7.x function; the 8.x methods are not really meant to be called directly, and if we make the 8.x patch that is suggested, we will lose the generic preDelete() and postDelete() documentation that we were inheriting, which is not a great thing really.
So on the 7.x patch...
- In the first line, "at first" should just be "first"... but....
- Can we make it two sentences, one about deleting the terms, and the other about the fields? The order actually doesn't matter, so instead of "first" and "then", we can just use "also".
- I think the end phrase about deleting "all Taxonomy module fields that use only this vocabulary" doesn't make sense in the context of having already updated the fields -- at that point, no taxonomy fields use the vocabulary, so what is being deleted is just the ones that are now empty of references. So maybe it would be clearer to say:
... update all Taxonomy fields so that they don't reference the deleted vocabulary, and then delete fields that have no remaining vocabulary references"
?
Comment #12
izus commentedhere it is :)
Thanks
Comment #13
jhodgdonPlease wrap the documentation so it all goes into one paragraph, or if you think it should be two separate paragraphs, put them on separate lines. Thanks!
We also need the documentation to state that all terms in the vocabulary are deleted.
Comment #14
izus commentedHi,
Here it is
Thanks for the review
Comment #15
jhodgdonThanks! That looks good to me.
Comment #16
jhodgdonThanks again! Committed to 7.x.