This patch moves the SQL query for deleting a node type out of the node_type_delete_confirm_submit() function (in content_types.inc), and into a new node_type_delete() function (in node.module). This was meant to go in with the original pre-CCK patch, but for some reason didn't seem to make it.

This is an important CRUD mechanism for the new configurable content types functionality, and as such it shouldn't be embedded as part of a specific _submit callback. It should be in its own reusable function (just as node_type_save() already is). Therefore, I think that this patch should go in for Drupal 5.0.

CommentFileSizeAuthor
#3 node_type_delete_0.patch3.34 KBJaza
node_type_delete.patch1.4 KBJaza

Comments

pwolanin’s picture

Category: task » bug

So this is also where we need the hook for modules to act upon node type deletion?

karens’s picture

I think we need to add this function to the node_types hook to handle the delete operation. Plus, we need to get the taxonomy module updated to remove deleted node types from its table, as reported in http://drupal.org/node/90497.

Does this patch need to be updated to add this operation to the node_types hook and update the taxonomy module, now that the patch to create the hook has been committed?

Jaza’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new3.34 KB

New patch with the following changes:

  1. The node_type_delete() function now invokes hook_node_type() with the 'delete' op.
  2. The node_node_type() function now checks that $op is not 'delete', before doing anything. We don't want to touch the 'type' field for nodes that are of a type that is being deleted - updating them will render them invalid, and deleting the nodes outright has already been agreed on as an unacceptable course of action.
  3. The taxonomy_node_type() function now deletes entries from the vocabulary_node_types table upon deletion of a node type.
  4. Also, I have followed alienbrain's advice in #9 of this thread, and removed all user messages regarding deletion of vocabulary associations. He's right, this is not relevant to the end-user at all, it's simply background maintaining of referential integrity, and displaying messages about it will simply annoy or confuse the user.

I tested this patch by creating a node type, creating nodes of that type, creating a vocabulary assigned to the node type, and then deleting the node type. Everything works as it should: nodes do not get touched, and vocabularies have the link deleted (otherwise they're untouched). Setting RTBC.

karens’s picture

I've tested this patch with latest head and latest cck. Taxonomy and content_type tables get updated correctly and the delete hook triggers my cck delete function, so it seems to be good to go as far as I can see.

I hope we can get this in before the next beta release since lots of people are trying out the cck integration and this is really needed for it to work right.

drumm’s picture

Status: Reviewed & tested by the community » Fixed

Committed to HEAD.

Anonymous’s picture

Status: Fixed » Closed (fixed)