From d48e3735a4f82c37214bbc19f2542d92ffce3fda Mon Sep 17 00:00:00 2001 From: Angela Byron Date: Tue, 17 May 2011 22:39:15 -0500 Subject: Issue #1017672 by catch, q0rban: Fixed D6 to D7 update process permanently deletes comment bodies and other data, and throws fatal SQL errors. --- modules/node/node.install | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'modules/node') diff --git a/modules/node/node.install b/modules/node/node.install index c5378dc85..14290e3ad 100644 --- a/modules/node/node.install +++ b/modules/node/node.install @@ -469,7 +469,26 @@ function node_update_dependencies() { * @ingroup update-api-6.x-to-7.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 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; } /** @@ -600,19 +619,6 @@ function node_update_7006(&$sandbox) { // Get node type info, specifically the body field settings. $node_types = _update_7000_node_get_types(); - // Create default settings for orphan nodes. - $extra_types = db_query('SELECT DISTINCT type FROM {node} WHERE type NOT IN (:types)', array(':types' => array_keys($node_types)))->fetchCol(); - foreach ($extra_types as $type) { - $type_object = new stdClass; - $type_object->type = $type; - // Always create a body. Querying node_revisions for a non-empty body - // would skip creating body fields for types that have a body but - // the nodes of that type so far had empty bodies. - $type_object->has_body = 1; - $type_object->body_label = 'Body'; - $node_types[$type_object->type] = $type_object; - } - // Add body field instances for existing node types. foreach ($node_types as $node_type) { if ($node_type->has_body) { -- cgit v1.2.3 From 75a0deb2722bde4fc7d60d02f186809fbc77320d Mon Sep 17 00:00:00 2001 From: webchick Date: Wed, 18 May 2011 00:07:38 -0500 Subject: Issue #1089174 by plach: Fixed Prepare view hooks do not receive the language parameter. --- modules/node/node.module | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'modules/node') diff --git a/modules/node/node.module b/modules/node/node.module index 4f079edd7..524a57fa7 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -1350,15 +1350,15 @@ function node_build_content($node, $view_mode = 'full', $langcode = NULL) { // The 'view' hook can be implemented to overwrite the default function // to display nodes. if (node_hook($node, 'view')) { - $node = node_invoke($node, 'view', $view_mode); + $node = node_invoke($node, 'view', $view_mode, $langcode); } // Build fields content. // In case of a multiple view, node_view_multiple() already ran the // 'prepare_view' step. An internal flag prevents the operation from running // twice. - field_attach_prepare_view('node', array($node->nid => $node), $view_mode); - entity_prepare_view('node', array($node->nid => $node)); + field_attach_prepare_view('node', array($node->nid => $node), $view_mode, $langcode); + entity_prepare_view('node', array($node->nid => $node), $langcode); $node->content += field_attach_view('node', $node, $view_mode, $langcode); // Always display a read more link on teasers because we have no way @@ -2513,8 +2513,8 @@ function node_feed($nids = FALSE, $channel = array()) { * An array in the format expected by drupal_render(). */ function node_view_multiple($nodes, $view_mode = 'teaser', $weight = 0, $langcode = NULL) { - field_attach_prepare_view('node', $nodes, $view_mode); - entity_prepare_view('node', $nodes); + field_attach_prepare_view('node', $nodes, $view_mode, $langcode); + entity_prepare_view('node', $nodes, $langcode); $build = array(); foreach ($nodes as $node) { $build['nodes'][$node->nid] = node_view($node, $view_mode, $langcode); -- cgit v1.2.3