Utility function: fetch the node types directly from the database.

This function is valid for a database schema version 7000.

Related topics

7 calls to _update_7000_node_get_types()
comment_update_7000 in modules/comment/comment.install
Rename comment display setting variables.
comment_update_7005 in modules/comment/comment.install
Create the comment_body field.
comment_update_7006 in modules/comment/comment.install
Migrate data from the comment field to field storage.
node_update_7006 in modules/node/node.install
Convert body and teaser from node properties to fields, and migrate status/comment/promote and sticky columns to the {node_revision} table.
system_update_7017 in modules/system/system.install
Change the theme setting 'toggle_node_info' into a per content type variable.

... See full list

File

modules/node/node.install, line 481
Install, update and uninstall functions for the node module.

Code

function _update_7000_node_get_types() {
  $node_types = db_query('SELECT * FROM {node_type}')
    ->fetchAllAssoc('type', PDO::FETCH_OBJ);

  // Create default settings for orphan 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;
}