commit c5d04a0a3ff563d44477a718ec5bb902b0ba6f97 Author: Lee Rowlands Date: Tue Sep 3 15:12:58 2013 +1000 Upgrade patch changes diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install index ab5b12a..28b274f 100644 --- a/core/modules/comment/comment.install +++ b/core/modules/comment/comment.install @@ -708,7 +708,6 @@ function comment_update_8007(&$sandbox) { if (count($nodes) > 0) { $insert = db_insert('node__comment_' . $sandbox['node_type']) ->fields(array( - 'entity_type', 'bundle', 'entity_id', 'revision_id', @@ -716,9 +715,8 @@ function comment_update_8007(&$sandbox) { 'delta', 'comment_' . $sandbox['node_type'] . '_status', )); - $revision = db_insert('node__comment_' . $sandbox['node_type']) + $revision = db_insert('node_revision__comment_' . $sandbox['node_type']) ->fields(array( - 'entity_type', 'bundle', 'entity_id', 'revision_id', @@ -730,13 +728,12 @@ function comment_update_8007(&$sandbox) { // Update the field name to match the node type. db_update('comment') ->fields(array( - 'field_id' => 'node.comment_' . $sandbox['node_type'], + 'field_id' => 'node__comment_' . $sandbox['node_type'], )) ->condition('entity_id', array_keys($nodes)) ->execute(); foreach ($nodes as $nid => $node) { $insert->values(array( - 'entity_type' => 'node', 'bundle' => $sandbox['node_type'], 'entity_id' => $nid, 'revision_id' => $node->vid, @@ -745,7 +742,6 @@ function comment_update_8007(&$sandbox) { 'comment_' . $sandbox['node_type'] . '_status' => $node->comment, )); $revision->values(array( - 'entity_type' => 'node', 'bundle' => $sandbox['node_type'], 'entity_id' => $nid, 'revision_id' => $node->vid, @@ -761,7 +757,7 @@ function comment_update_8007(&$sandbox) { // Populate the field name to match the node type. db_update('comment_entity_statistics') ->fields(array( - 'field_id' => 'node.comment_' . $sandbox['node_type'], + 'field_id' => 'node__comment_' . $sandbox['node_type'], )) ->condition('entity_id', array_keys($nodes)) ->execute(); diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/CommentUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/CommentUpgradePathTest.php index f0af6b7..92aa9ce 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/CommentUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/CommentUpgradePathTest.php @@ -102,7 +102,7 @@ public function testCommentUpgrade() { sort($types); $this->assertIdentical(array_keys($expected_settings), $types, 'All node types are upgraded'); foreach ($types as $type) { - $instance = field_info_instance('node', 'comment_node_' . $type, $type); + $instance = field_info_instance('node', 'comment_' . $type, $type); $this->assertTrue($instance, format_string('Comment field found for the %type node type', array( '%type' => $type ))); commit 41c57d571f122adef328db6440016e9ea479598d Author: Lee Rowlands Date: Tue Sep 3 15:13:13 2013 +1000 Fixes forum diff --git a/core/modules/forum/forum.install b/core/modules/forum/forum.install index d4d9b5e..1471854 100644 --- a/core/modules/forum/forum.install +++ b/core/modules/forum/forum.install @@ -110,8 +110,8 @@ function forum_enable() { ->save(); } // Add the comment field to the forum node type. - if (!field_read_field('comment_node_forum', array('include_inactive' => TRUE))) { - comment_add_default_comment_field('node', 'forum', 'comment_node_forum', COMMENT_OPEN); + if (!field_read_field('comment_forum', array('include_inactive' => TRUE))) { + comment_add_default_comment_field('node', 'forum', 'comment_forum', COMMENT_OPEN); } } @@ -138,17 +138,13 @@ function forum_uninstall() { $field->delete(); } -<<<<<<< HEAD // Load the dependent Comment module, in case it has been disabled. drupal_load('module', 'comment'); - if ($field = field_info_field('comment_node_forum')) { + if ($field = field_info_field('node', 'comment_forum')) { $field->delete(); } - // Purge field data now to allow taxonomy module to be uninstalled - // if this is the only field remaining. -======= if ($field = field_info_field('taxonomy_term', 'forum_container')) { $field->delete(); } @@ -158,7 +154,6 @@ function forum_uninstall() { // field_purge_batch() will not remove the instance and the field in the same // pass. field_purge_batch(10); ->>>>>>> origin/8.x field_purge_batch(10); // Allow to delete a forum's node type. $locked = Drupal::state()->get('node.type.locked'); diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index d377038..1ba79f4 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -485,7 +485,7 @@ function forum_permission() { */ function forum_comment_publish($comment) { if ($comment->entity_type->value == 'node') { - Drupal::service('forum_manager')->updateIndex($comment->nid->target_id); + Drupal::service('forum_manager')->updateIndex($comment->entity_id->value); } } @@ -499,7 +499,7 @@ function forum_comment_update($comment) { // $comment->save() calls hook_comment_publish() for all published comments, // so we need to handle all other values here. if (!$comment->status->value && $comment->entity_type->value == 'node') { - Drupal::service('forum_manager')->updateIndex($comment->nid->target_id); + Drupal::service('forum_manager')->updateIndex($comment->entity_id->value); } } @@ -508,7 +508,7 @@ function forum_comment_update($comment) { */ function forum_comment_unpublish($comment) { if ($comment->entity_type->value == 'node') { - Drupal::service('forum_manager')->updateIndex($comment->nid->target_id); + Drupal::service('forum_manager')->updateIndex($comment->entity_id->value); } } @@ -517,7 +517,7 @@ function forum_comment_unpublish($comment) { */ function forum_comment_delete($comment) { if ($comment->entity_type->value == 'node') { - Drupal::service('forum_manager')->updateIndex($comment->nid->target_id); + Drupal::service('forum_manager')->updateIndex($comment->entity_id->value); } } diff --git a/core/modules/forum/lib/Drupal/forum/ForumManager.php b/core/modules/forum/lib/Drupal/forum/ForumManager.php index 6763f6b..c528951 100644 --- a/core/modules/forum/lib/Drupal/forum/ForumManager.php +++ b/core/modules/forum/lib/Drupal/forum/ForumManager.php @@ -185,7 +185,7 @@ public function getTopics($tid) { ->extend('Drupal\Core\Database\Query\TableSortExtender'); $query->fields('n', array('nid')); - $query->join('comment_entity_statistics', 'ces', "n.nid = ces.entity_id AND ces.field_id = 'node.comment_node_forum' AND ces.entity_type = 'node'"); + $query->join('comment_entity_statistics', 'ces', "n.nid = ces.entity_id AND ces.field_id = 'node__comment_forum' AND ces.entity_type = 'node'"); $query->fields('ces', array( 'cid', 'last_comment_uid', @@ -193,7 +193,7 @@ public function getTopics($tid) { 'comment_count' )); - $query->join('forum_index', 'f', 'f.nid = ncs.nid'); + $query->join('forum_index', 'f', 'f.nid = n.nid'); $query->addField('f', 'tid', 'forum_tid'); $query->join('users', 'u', 'n.uid = u.uid'); @@ -356,7 +356,7 @@ protected function getLastPost($tid) { // Query "Last Post" information for this forum. $query = $this->connection->select('node_field_data', 'n'); $query->join('forum', 'f', 'n.vid = f.vid AND f.tid = :tid', array(':tid' => $tid)); - $query->join('comment_entity_statistics', 'ces', "n.nid = ces.entity_id AND ces.field_id = 'node.comment_node_forum' AND ces.entity_type = 'node'"); + $query->join('comment_entity_statistics', 'ces', "n.nid = ces.entity_id AND ces.field_id = 'node__comment_forum' AND ces.entity_type = 'node'"); $query->join('users', 'u', 'ces.last_comment_uid = u.uid'); $query->addExpression('CASE ces.last_comment_uid WHEN 0 THEN ces.last_comment_name ELSE u.name END', 'last_comment_name'); @@ -394,7 +394,7 @@ protected function getForumStatistics($tid) { if (empty($this->forumStatistics)) { // Prime the statistics. $query = $this->connection->select('node_field_data', 'n'); - $query->join('comment_entity_statistics', 'ces', "n.nid = ces.entity_id AND ces.field_id = 'node.comment_node_forum' AND ces.entity_type = 'node'"); + $query->join('comment_entity_statistics', 'ces', "n.nid = ces.entity_id AND ces.field_id = 'node__comment_forum' AND ces.entity_type = 'node'"); $query->join('forum', 'f', 'n.vid = f.vid'); $query->addExpression('COUNT(n.nid)', 'topic_count'); $query->addExpression('SUM(ces.comment_count)', 'comment_count'); @@ -515,14 +515,14 @@ public function unreadTopics($term, $uid) { * {@inheritdoc} */ public function updateIndex($nid) { - $count = $this->connection->query('SELECT COUNT(cid) FROM {comment} c INNER JOIN {forum_index} i ON c.nid = i.nid WHERE c.nid = :nid AND c.status = :status', array( + $count = $this->connection->query("SELECT COUNT(cid) FROM {comment} c INNER JOIN {forum_index} i ON c.entity_id = i.nid WHERE c.entity_id = :nid AND c.field_id = 'node__comment_forum' AND c.entity_type = 'node' AND c.status = :status", array( ':nid' => $nid, ':status' => COMMENT_PUBLISHED, ))->fetchField(); if ($count > 0) { // Comments exist. - $last_reply = $this->connection->queryRange('SELECT cid, name, created, uid FROM {comment} WHERE nid = :nid AND status = :status ORDER BY cid DESC', 0, 1, array( + $last_reply = $this->connection->queryRange("SELECT cid, name, created, uid FROM {comment} WHERE entity_id = :nid AND field_id = 'node__comment_forum' AND entity_type = 'node' AND status = :status ORDER BY cid DESC", 0, 1, array( ':nid' => $nid, ':status' => COMMENT_PUBLISHED, ))->fetchObject();