diff --git a/modules/node/node.install b/modules/node/node.install index 4a02baa2c48446e9fab7b031b24f3c1b3d4b234b..e322e81c0a41ce190e2325143ca1e311cfb1d498 100644 --- a/modules/node/node.install +++ b/modules/node/node.install @@ -449,5 +449,23 @@ function node_install() { * @ingroup update-api-7.x-to-8.x */ function _update_7000_node_get_types() { - return db_query('SELECT * FROM {node_type}')->fetchAllAssoc('type', PDO::FETCH_OBJ); + $node_types = db_query('SELECT * FROM {node_type}')->fetchAllAssoc('type', PDO::FETCH_OBJ); + + // Create default settings for orphaned nodes. + $all_types = db_query('SELECT DISTINCT type FROM {node}')->fetchCol(); + $extra_types = array_diff($all_types, array_keys($node_types)); + + foreach ($extra_types as $type) { + $type_object = new stdClass; + $type_object->type = $type; + // In Drupal 6, whether you have a body field or not is a flag in the node + // type table. If it's enabled, nodes may or may not have an empty string + // for the bodies. As we can't detect what this setting should be in + // Drupal 7 without access to the Drupal 6 node type settings, we assume + // the default, which is to enable the body field. + $type_object->has_body = 1; + $type_object->body_label = 'Body'; + $node_types[$type_object->type] = $type_object; + } + return $node_types; }