Download & Extend

node_type_delete() invokes hook on no data

Project:Drupal core
Version:5.x-dev
Component:node system
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (won't fix)

Issue Summary

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.

AttachmentSizeStatusTest resultOperations
node_type_delete_3.patch486 bytesIgnored: Check issue status.NoneNone

Comments

#1

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

#2

Status:needs review» 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

Status:reviewed & tested by the community» fixed

Thanks, committed.

#4

Version:6.x-dev» 5.x-dev
Status:fixed» patch (to be ported)

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

#5

Status:patch (to be ported)» closed (won't fix)

Marking as won't fix as d5 is end of life.