diff --git a/modules/field/field.install b/modules/field/field.install index 2d7d28f..16b09e1 100644 --- a/modules/field/field.install +++ b/modules/field/field.install @@ -172,7 +172,7 @@ function field_schema() { * * @ingroup update-api-7.x-to-8.x */ -function _update_8000_field_create_field(&$field) { +function _update_7000_field_create_field(&$field) { // Merge in default values.` $field += array( 'entity_types' => array(), @@ -243,14 +243,14 @@ function _update_8000_field_create_field(&$field) { * To protect user data, this function can only be used to delete fields once * all information it stored is gone. Delete all data from the * field_data_$field_name table before calling by either manually issuing - * delete queries against it or using _update_8000_field_delete_instance(). + * delete queries against it or using _update_7000_field_delete_instance(). * * @param $field_name * The field name to delete. * * @ingroup update-api-7.x-to-8.x */ -function _update_8000_field_delete_field($field_name) { +function _update_7000_field_delete_field($field_name) { $table_name = 'field_data_' . $field_name; if (db_select($table_name)->range(0, 1)->countQuery()->execute()->fetchField()) { $t = get_t(); @@ -279,7 +279,7 @@ function _update_8000_field_delete_field($field_name) { * * @ingroup update-api-7.x-to-8.x */ -function _update_8000_field_delete_instance($field_name, $entity_type, $bundle) { +function _update_7000_field_delete_instance($field_name, $entity_type, $bundle) { // Delete field instance configuration data. db_delete('field_config_instance') ->condition('field_name', $field_name) @@ -317,7 +317,7 @@ function _update_8000_field_delete_instance($field_name, $entity_type, $bundle) * by the $key parameter. * @ingroup update-api-7.x-to-8.x */ -function _update_8000_field_read_fields(array $conditions = array(), $key = 'id') { +function _update_7000_field_read_fields(array $conditions = array(), $key = 'id') { $fields = array(); $query = db_select('field_config', 'fc', array('fetch' => PDO::FETCH_ASSOC)) ->fields('fc'); @@ -349,7 +349,7 @@ function _update_8000_field_read_fields(array $conditions = array(), $key = 'id' * * @ingroup update-api-7.x-to-8.x */ -function _update_8000_field_create_instance($field, &$instance) { +function _update_7000_field_create_instance($field, &$instance) { // Merge in defaults. $instance += array( 'field_id' => $field['id'], diff --git a/modules/field/modules/field_sql_storage/field_sql_storage.install b/modules/field/modules/field_sql_storage/field_sql_storage.install index 930686d..4a3a00e 100644 --- a/modules/field/modules/field_sql_storage/field_sql_storage.install +++ b/modules/field/modules/field_sql_storage/field_sql_storage.install @@ -29,7 +29,7 @@ function field_sql_storage_schema() { * * @ingroup update-api-7.x-to-8.x */ -function _update_8000_field_sql_storage_write($entity_type, $bundle, $entity_id, $revision_id, $field_name, $data) { +function _update_7000_field_sql_storage_write($entity_type, $bundle, $entity_id, $revision_id, $field_name, $data) { $table_name = "field_data_{$field_name}"; $revision_name = "field_revision_{$field_name}"; diff --git a/modules/node/node.install b/modules/node/node.install index 4a02baa..fcc1f00 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; + // A node type may be created with the body setting enabled, however even if + // that setting is enabled, individual nodes may be have been created with + // empty bodies. There is no way to detect the difference between these + // two states without access to the original node type settings, so 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; }