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

jhodgdon’s picture

Well... that seems like necessary housekeeping that would be implied if you delete a vocabulary, but sure we could document it.

joachim’s picture

> 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.

jhodgdon’s picture

Good point. Patch?

izus’s picture

Status: Active » Needs review
StatusFileSize
new485 bytes

hi,
i suggest following patch.

Thanks

jhodgdon’s picture

Version: 7.x-dev » 8.x-dev
Status: Needs review » Needs work

Looks 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.

joachim’s picture

These are API functions that are intended for general use, therefore I think they should describe what they do.

izus’s picture

Hi,
here are suggested patches for D8 and D7
Thanks

Status: Needs review » Needs work

The last submitted patch, 7: taxonomy_vocabulary_delete-documentation-2182187-7-D7.patch, failed testing.

The last submitted patch, 7: taxonomy_vocabulary_delete-documentation-2182187-7-D7.patch, failed testing.

izus’s picture

Status: Needs work » Needs review
StatusFileSize
new587 bytes

oups !
i forget to mention do-not-test for the D7 patch

jhodgdon’s picture

Version: 8.x-dev » 7.x-dev
Status: Needs review » Needs work

Hm. 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...

+ * This will at first update all Taxonomy fields so that they don't reference
+ * the deleted vocabulary and then delete all the terms of the vocabulary and
+ * all Taxonomy module fields that use only this vocabulary.

- 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"

?

izus’s picture

Status: Needs work » Needs review
StatusFileSize
new542 bytes

here it is :)
Thanks

jhodgdon’s picture

Status: Needs review » Needs work

Please 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.

izus’s picture

Status: Needs work » Needs review
StatusFileSize
new616 bytes

Hi,
Here it is
Thanks for the review

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Thanks! That looks good to me.

jhodgdon’s picture

Status: Reviewed & tested by the community » Fixed

Thanks again! Committed to 7.x.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.