diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 6f6c04b..676b8ee 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -1618,10 +1618,6 @@ function comment_delete_multiple($cids) { if ($comments) { $transaction = db_transaction(); try { - // Delete the comments. - db_delete('comment') - ->condition('cid', array_keys($comments), 'IN') - ->execute(); foreach ($comments as $comment) { field_attach_delete('comment', $comment); module_invoke_all('comment_delete', $comment); @@ -1630,6 +1626,16 @@ function comment_delete_multiple($cids) { // Delete the comment's replies. $child_cids = db_query('SELECT cid FROM {comment} WHERE pid = :cid', array(':cid' => $comment->cid))->fetchCol(); comment_delete_multiple($child_cids); + } + + // Delete the comments. + db_delete('comment') + ->condition('cid', array_keys($comments), 'IN') + ->execute(); + + // Now update the node statistics. This has to be done after all the data + // of the comments are gone. + foreach ($comments as $comment) { _comment_update_node_statistics($comment->nid); } } diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 7ad28e9..47fdacb 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -474,14 +474,15 @@ function taxonomy_vocabulary_delete($vid) { 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'); + db_delete('taxonomy_vocabulary') + ->condition('vid', $vid) + ->execute(); + // Load all Taxonomy module fields and delete those which use only this // vocabulary. $taxonomy_fields = field_read_fields(array('module' => 'taxonomy')); @@ -717,16 +718,15 @@ function taxonomy_term_delete($tid) { } if ($term = taxonomy_term_load($tid)) { + field_attach_delete('taxonomy_term', $term); + module_invoke_all('taxonomy_term_delete', $term); + module_invoke_all('entity_delete', $term, 'taxonomy_term'); db_delete('taxonomy_term_data') ->condition('tid', $tid) ->execute(); db_delete('taxonomy_term_hierarchy') ->condition('tid', $tid) ->execute(); - - field_attach_delete('taxonomy_term', $term); - module_invoke_all('taxonomy_term_delete', $term); - module_invoke_all('entity_delete', $term, 'taxonomy_term'); taxonomy_terms_static_reset(); } }