Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1336
diff -u -p -r1.1336 node.module
--- modules/node/node.module	3 Jan 2011 18:03:54 -0000	1.1336
+++ modules/node/node.module	6 Jan 2011 09:48:10 -0000
@@ -614,16 +614,20 @@ function node_field_extra_fields() {
 /**
  * Deletes a node type from the database.
  *
- * @param $type
+ * @param $bundle_name
  *   The machine-readable name of the node type to be deleted.
  */
+
 function node_type_delete($type) {
-  $info = node_type_get_type($type);
   db_delete('node_type')
     ->condition('type', $type)
     ->execute();
   field_attach_delete_bundle('node', $type);
-  module_invoke_all('node_type_delete', $info);
+
+  $node_types = _node_types_build(TRUE)->types;
+  if (isset($node_types[$type])){
+    module_invoke_all('node_type_delete', $node_types[$type]);
+  }
 
   // Clear the node type cache.
   node_type_cache_reset();
Index: modules/node/node.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.test,v
retrieving revision 1.106
diff -u -p -r1.106 node.test
--- modules/node/node.test	17 Dec 2010 19:28:14 -0000	1.106
+++ modules/node/node.test	6 Jan 2011 09:48:10 -0000
@@ -1141,14 +1141,25 @@ class NodeTypeTestCase extends DrupalWeb
   /**
    * Test creating a content type programmatically and via a form.
    */
-  function testNodeTypeCreation() {
-    // Create a content type programmaticaly.
+  function testNodeTypeCreateDelete() {
+    // Create and delete a content type programmaticaly.
     $type = $this->drupalCreateContentType();
-
     $type_exists = db_query('SELECT 1 FROM {node_type} WHERE type = :type', array(':type' => $type->type))->fetchField();
     $this->assertTrue($type_exists, 'The new content type has been created in the database.');
+    node_type_delete($type->name);
+    $type_exists = db_query('SELECT 1 FROM {node_type} WHERE type = :type', array(':type' => $type->type))->fetchField();
+    $this->assertFalse($type_exists, 'The new content type has been deleted from the database.');
 
+    // Create, disable and delete a content type programmaticaly.
+    // Disabling a content type simulates disabling a module which creates the content type
+    $type = $this->drupalCreateContentType();
+    db_query("UPDATE {node_type} SET disabled = TRUE WHERE type = :type", array(':type' => $type->type));
+    node_type_delete($type->name);
+    $type_exists = db_query('SELECT 1 FROM {node_type} WHERE type = :type', array(':type' => $type->type))->fetchField();
+    $this->assertFalse($type_exists, 'A disabled content type has been deleted from the database.');
+    
     // Login a test user.
+    $type = $this->drupalCreateContentType();
     $web_user = $this->drupalCreateUser(array('create ' . $type->name . ' content'));
     $this->drupalLogin($web_user);

