Index: modules/node/node.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.install,v
retrieving revision 1.53
diff -u -p -r1.53 node.install
--- modules/node/node.install	22 Aug 2010 13:55:53 -0000	1.53
+++ modules/node/node.install	31 Aug 2010 14:07:54 -0000
@@ -470,7 +470,7 @@ function node_update_7004() {
 
   // Map old preview setting to new values order.
   $original_preview ? $original_preview = 2 : $original_preview = 1;
-  drupal_static_reset('_node_types_build');
+  node_type_reset();
   $type_list = node_type_get_types();
 
   // Apply original settings to all types.
@@ -502,7 +502,7 @@ function node_update_7006(&$sandbox) {
   $sandbox['#finished'] = 0;
 
   // Get node type info for every invocation.
-  drupal_static_reset('_node_types_build');
+  node_type_reset();
   $node_types = node_type_get_types();
 
   if (!isset($sandbox['total'])) {
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1294
diff -u -p -r1.1294 node.module
--- modules/node/node.module	30 Aug 2010 05:58:46 -0000	1.1294
+++ modules/node/node.module	31 Aug 2010 14:25:49 -0000
@@ -465,7 +465,7 @@ function node_type_get_name($node) {
  */
 function node_types_rebuild() {
   // Reset and load updated node types.
-  drupal_static_reset('_node_types_build');
+  node_type_reset();
   foreach (node_type_get_types() as $type => $info) {
     if (!empty($info->is_new)) {
       node_type_save($info);
@@ -543,7 +543,7 @@ function node_type_save($info) {
   }
 
   // Clear the node type cache.
-  drupal_static_reset('_node_types_build');
+  node_type_reset();
 
   return $status;
 }
@@ -634,7 +634,7 @@ function node_type_delete($type) {
   module_invoke_all('node_type_delete', $info);
 
   // Clear the node type cache.
-  drupal_static_reset('_node_types_build');
+  node_type_reset();
 }
 
 /**
@@ -681,6 +681,12 @@ function _node_types_build() {
   if (is_object($_node_types)) {
     return $_node_types;
   }
+
+  if ($cache = cache_get('node_types')) {
+    $_node_types = $cache->data;
+    return $_node_types;
+  }
+
   $_node_types = (object)array('types' => array(), 'names' => array());
 
   $info_array = module_invoke_all('node_info');
@@ -716,10 +722,20 @@ function _node_types_build() {
 
   asort($_node_types->names);
 
+  cache_set('node_types', $_node_types);
+
   return $_node_types;
 }
 
 /**
+ * Clears the node type cache.
+ */
+function node_type_reset() {
+  cache_clear_all('node_types', 'cache');
+  drupal_static_reset('_node_types_build');
+}
+
+/**
  * Set the default values for a node type.
  *
  * The defaults are for a type defined through hook_node_info().
@@ -730,32 +746,25 @@ function _node_types_build() {
  *   An object or array containing values to override the defaults.
  *
  * @return
- *  A node type object.
+ *   A node type object.
  */
 function node_type_set_defaults($info = array()) {
-  $type = &drupal_static(__FUNCTION__);
-
-  if (!isset($type)) {
-    $type = new stdClass();
-    $type->type = '';
-    $type->name = '';
-    $type->base = '';
-    $type->description = '';
-    $type->help = '';
-    $type->custom = 0;
-    $type->modified = 0;
-    $type->locked = 1;
-    $type->is_new = 1;
-
-    $type->has_title = 1;
-    $type->title_label = 'Title';
-  }
-
-  $new_type = clone $type;
   $info = (array) $info;
-  foreach ($info as $key => $data) {
-    $new_type->$key = $data;
-  }
+  $new_type = $info + array(
+    'type' => '',
+    'name' => '',
+    'base' => '',
+    'description' => '',
+    'help' => '',
+    'custom' => 0,
+    'modified' => 0,
+    'locked' => 1,
+    'is_new' => 1,
+    'has_title' => 1,
+    'title_label' => 'Title',
+  );
+
+  $new_type = (object) $new_type;
   // If the type has no title, set an empty label.
   if (!$new_type->has_title) {
     $new_type->title_label = '';
@@ -1866,7 +1875,7 @@ function node_menu() {
   // @todo Remove this loop when we have a 'description callback' property.
   // Reset internal static cache of _node_types_build(), forces to rebuild the
   // node type information.
-  drupal_static_reset('_node_types_build');
+  node_type_reset();
   foreach (node_type_get_types() as $type) {
     $type_url_str = str_replace('_', '-', $type->type);
     $items['node/add/' . $type_url_str] = array(
Index: modules/node/node.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.test,v
retrieving revision 1.94
diff -u -p -r1.94 node.test
--- modules/node/node.test	30 Aug 2010 00:22:03 -0000	1.94
+++ modules/node/node.test	31 Aug 2010 14:19:56 -0000
@@ -577,6 +577,8 @@ class SummaryLengthTestCase extends Drup
 }
 
 class NodeTitleXSSTestCase extends DrupalWebTestCase {
+  protected $profile = 'testing';
+
   public static function getInfo() {
     return array(
       'name' => 'Node title XSS filtering',
@@ -585,6 +587,16 @@ class NodeTitleXSSTestCase extends Drupa
     );
   }
 
+  function setUp() {
+    parent::setUp();
+
+    $this->drupalCreateContentType(array(
+      'type' => 'page',
+      'name' => t('Basic page'),
+      'base' => 'node_content',
+    ));
+  }
+
   function testNodeTitleXSS() {
     // Prepare a user to do the stuff.
     $web_user = $this->drupalCreateUser(array('create page content', 'edit any page content'));
@@ -592,8 +604,10 @@ class NodeTitleXSSTestCase extends Drupa
 
     $xss = '<script>alert("xss")</script>';
     $title = $xss . $this->randomName();
-    $edit = array("title" => $title);
 
+    $this->drupalGet('node/add');
+
+    $edit = array("title" => $title);
     $this->drupalPost('node/add/page', $edit, t('Preview'));
     $this->assertNoRaw($xss, t('Harmful tags are escaped when previewing a node.'));
 
