Call insert/delete hooks for node types like 'book'

yasenp - May 12, 2007 - 16:42
Project:Nodetype
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:active
Description

Current version of the 'nodetype' module just changes the 'type' field in the 'node' table, but sometimes this is not enough, for example, when changing type to 'book' a record in 'book' table should be created, and if the type was 'forum', then the correspondent record in the 'forum' table should be deleted. Currently this is not done, so the record remains in the list of forum posts and doesn't appear in the list of books.
The patch adds calls to the 'delete' node hook before changing type and to the 'insert' node hook after changing type. This doesn't always give ideal result, but at least it gives better result than before.

AttachmentSize
nodetype.module.patch679 bytes

#1

markus_petrux - December 13, 2007 - 18:00

Invoking 'delete' node hook will remove comments, if any. And that's just an example of colateral issues that may happen when deleting a node. I guess changing node types is not a easy as it seems.

#2

dww - March 25, 2008 - 19:25
Priority:normal» critical

Yeah, this is a pretty serious failing of this module. As another example, if you're changing from 1 CCK node type to another, the old field data is left in the {content_type_foo} table and no new record is created in the {content_type_bar} table. E.g. if you convert an "event" into something else, the DB still has event info for it, calendar views are still confused, etc.

Agreed, changing node types isn't easy, but just updating the type field in the {node} table is definitely insufficient in the vast majority of cases...

 
 

Drupal is a registered trademark of Dries Buytaert.