The function that I found triggering the hook_taxonomy_vocabulary_delete

function taxonomy_vocabulary_delete($vid) {
  $vocabulary = (array) taxonomy_vocabulary_load($vid);

  // Only load terms without a parent, child terms will get deleted too.
  $result = db_query('SELECT t.tid FROM {taxonomy_term_data} t INNER JOIN {taxonomy_term_hierarchy} th ON th.tid = t.tid WHERE t.vid = :vid AND th.parent = 0', array(':vid' => $vid))->fetchCol();
  foreach ($result as $tid) {
    taxonomy_term_delete($tid);
  }
  db_delete('taxonomy_vocabulary')
    ->condition('vid', $vid)
    ->execute();

  field_attach_delete_bundle('taxonomy_term', $vocabulary['machine_name']);
  module_invoke_all('taxonomy_vocabulary_delete', $vocabulary);
  module_invoke_all('entity_delete', $vocabulary, 'taxonomy_vocabulary');

  cache_clear_all();
  entity_get_controller('taxonomy_vocabulary')->resetCache();

  return SAVED_DELETED;
}

The documentation for the hook:

/**
 * Respond to the deletion of taxonomy vocabularies.
 *
 * Modules implementing this hook can respond to the deletion of taxonomy
 * vocabularies from the database.
 *
 * @param $vocabulary
 *   A taxonomy vocabulary object.
 */
function hook_taxonomy_vocabulary_delete($vocabulary) {
  if (variable_get('taxonomy_' . $vocabulary->vid . '_synonyms', FALSE)) {
    variable_del('taxonomy_' . $vocabulary->vid . '_synonyms');
  }
}

In the actual code, the $vocabolary is cast to array, but in the documentation, the $vocabolary is used as an object.

I've attached a patch with the needed documentation fixes.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yched’s picture

Passing a vocab as an array sounds weird.

hook_entity_delete() also expects an object, so this is most probably an overlook when the hooks invocations were added.

yched’s picture

Status: Active » Closed (duplicate)

Indeed, those two hook invocations were added in #709892: Complete entity CRUD hook invocations. Posted a note over there, for now marking as duplicate.

yched’s picture

Status: Closed (duplicate) » Needs review
FileSize
1.11 KB

Actually, I have no clue why we have this array cast.

Let's try simply removing it - and the issue is probably best handled in this thread.

yched’s picture

Title: hook_taxonomy_vocabulary_delete documentation is flawed. » hook_taxo_vocab_delete gets $vocab as an array

change title accordingly

sun’s picture

Priority: Normal » Major
Status: Needs review » Reviewed & tested by the community
Issue tags: -Documentation
catch’s picture

Array cast makes no sense to me either. It's likely it's just been there for a long time and not removed until now. Confirming rtbc.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Yeah, it looks like every other hook_taxonomy_foo() function takes the term/vocab as an object, so this is weird here. According to testbot this doesn't break anything.

Committed to HEAD.

Status: Fixed » Closed (fixed)

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