Index: /Applications/MAMP/htdocs/freetags/drupal/sites/all/modules/comment_alter_taxonomy/comment_alter_taxonomy.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/comment_alter_taxonomy/comment_alter_taxonomy.module,v
retrieving revision 1.6
diff -u -p -r1.6 comment_alter_taxonomy.module
--- comment_alter_taxonomy.module	27 Sep 2008 21:38:07 -0000	1.6
+++ comment_alter_taxonomy.module	27 Sep 2008 22:15:57 -0000
@@ -713,6 +713,30 @@ function comment_alter_taxonomy_get_alte
   return $vocabularies[$type];
 }
 
+/**
+ * Implementation of hook_taxonomy().
+ *
+ * Handle deletion of terms and vocabularies from the database.
+ */
+function comment_alter_taxonomy_taxonomy($op, $type, $array = NULL) {
+  if ($op == delete) {
+    if ($type == 'vocabulary') {
+      // Delete this vocabulary from the comment_alter_taxonomy_vocabularies variable.
+      // When a vocabulary is deleted this hook is first called for each term
+      // in the vocabulary, so those rows will already be deleted by the time
+      // execution gets here.
+      $vocabularies = variable_get('comment_alter_taxonomy_vocabularies', array());
+      if (isset($vocabularies[$array['vid']])) {
+        unset($vocabularies[$array['vid']]);
+        variable_set('comment_alter_taxonomy_vocabularies', $vocabularies);
+      }
+    }
+
+    // Delete the rows in {comment_alter_taxonomy} for the term.
+    db_query('DELETE FROM {comment_alter_taxonomy} WHERE tid = %d', $tids);
+  }
+}
+
 // Unresolved problems:
 // TODO:  What do do when a comment is deleted.
 // TODO:  What do to when a comment is unpublished.
