node_type_delete() invokes hook on no data

njivy - February 5, 2007 - 19:50
Project:Drupal
Version:5.x-dev
Component:node system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:patch (to be ported)
Description

Here is what I experienced:

1. Called node_type_delete('my_content_type') from hook_uninstall()
2. node_type_delete() deleted from {node_type}
3. node_type_delete() called node_get_types(), which had not yet been initialized
4. node_type_delete() called module_invoke('node_type', 'delete', $info) with an empty variable
5. content_type_delete() failed

As-is, it works when deleting content types from the administrative page. We didn't notice this problem until now because node_menu() calls node_get_types() for the administrative pages, which initializes a static variable before node_type_delete() deletes from {node_types}.

The attached patch swaps two lines, calling node_get_types() before deleting from {node_type} in every case.

I experienced this with Drupal 5.x, but I see the same thing in Drupal 6.x so I am marking this for 6.x-dev.

AttachmentSize
node_type_delete_3.patch486 bytes

#1

dmitrig01 - February 27, 2007 - 05:24

+1. Great. I would mark it as RTBC if more people reviewed it.

#2

hunmonk - October 5, 2007 - 21:48
Status:patch (code needs review)» patch (reviewed & tested by the community)

this is still a problem i ran into in HEAD when working on http://drupal.org/node/180432

tested, and works as advertized.

#3

Gábor Hojtsy - October 8, 2007 - 13:04
Status:patch (reviewed & tested by the community)» fixed

Thanks, committed.

#4

Gábor Hojtsy - October 8, 2007 - 13:05
Version:6.x-dev» 5.x-dev
Status:fixed» patch (to be ported)

Erm, also an issue in 5.x, so needs backporting.

 
 

Drupal is a registered trademark of Dries Buytaert.