diff --git a/modules/node/content_types.inc b/modules/node/content_types.inc index 5a22f363c79883982c13d97ab50a02a2a0c0baf9..368a449858b1a183e7d1c8c0c27bbc6f1b7dc8b7 100644 --- a/modules/node/content_types.inc +++ b/modules/node/content_types.inc @@ -331,7 +331,7 @@ function node_type_form_submit($form_id, $form_values) { * Implementation of hook_node_type(). */ function node_node_type($op, $info) { - if (!empty($info->old_type) && $info->old_type != $info->type) { + if ($op != 'delete' && !empty($info->old_type) && $info->old_type != $info->type) { $update_count = node_type_update_nodes($info->old_type, $info->type); if ($update_count) { @@ -387,7 +387,7 @@ function node_type_delete_confirm($type) { * Process content type delete confirm submissions. */ function node_type_delete_confirm_submit($form_id, $form_values) { - db_query("DELETE FROM {node_type} WHERE type = '%s'", $form_values['type']); + node_type_delete($form_values['type']); $t_args = array('%name' => $form_values['name']); drupal_set_message(t('The content type %name has been deleted.', $t_args)); @@ -398,4 +398,3 @@ function node_type_delete_confirm_submit($form_id, $form_values) { return 'admin/content/types'; } - diff --git a/modules/node/node.module b/modules/node/node.module index ae3a0a6d07e9047bc23e8913237da97a8ee9598a..4c55d1aa6d8631a822995887d497f492dafbca81 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -294,6 +294,19 @@ function node_type_save($info) { } } +/** + * Deletes a node type from the database. + * + * @param $type + * The machine-readable name of the node type to be deleted. + */ +function node_type_delete($type) { + db_query("DELETE FROM {node_type} WHERE type = '%s'", $type); + + $info = node_get_types('type', $type); + module_invoke_all('node_type', 'delete', $info); +} + /** * Updates all nodes of one type to be of another type. * diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 40fde59c7adb54967c6397c6e60ac81a904b0047..b38bde5792d62bbf9479ee5e3a13409603e8591d 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -818,16 +818,10 @@ function taxonomy_node_delete($nid) { */ function taxonomy_node_type($op, $info) { if ($op == 'update' && !empty($info->old_type) && $info->type != $info->old_type) { - if (db_num_rows(db_query("SELECT * from {vocabulary_node_types} WHERE type = '%s'", $info->old_type))) { - db_query("UPDATE {vocabulary_node_types} SET type = '%s' WHERE type = '%s'", $info->type, $info->old_type); - $num_updated = db_affected_rows(); - - if ($num_updated) { - $substr_pre = 'Changed the content type association of '; - $substr_post = strtr(' from %old-type to %type.', array('%old-type' => theme('placeholder', $info->old_type), '%type' => theme('placeholder', $info->type))); - drupal_set_message(format_plural($num_updated, $substr_pre .'1 vocabulary'. $substr_post, $substr_pre .'@count vocabularies'. $substr_post)); - } - } + db_query("UPDATE {vocabulary_node_types} SET type = '%s' WHERE type = '%s'", $info->type, $info->old_type); + } + elseif ($op == 'delete') { + db_query("DELETE FROM {vocabulary_node_types} WHERE type = '%s'", $info->type); } }