diff --git a/core/modules/comment/comment.field.inc b/core/modules/comment/comment.field.inc index d1f3147..9e7b7dd 100644 --- a/core/modules/comment/comment.field.inc +++ b/core/modules/comment/comment.field.inc @@ -121,18 +121,6 @@ function comment_instance_settings_translation_entity_process($element, $form_st } /** - * Implements hook_field_widget_info_alter(). - * - * @todo convert this to a WidgetPlugin annotation. - */ -function comment_field_widget_info_alter(&$info) { - $info['comment_default']['behaviors'] = array( - 'multiple values' => FIELD_BEHAVIOR_CUSTOM, - 'default value' => FIELD_BEHAVIOR_NONE, - ); -} - -/** * Implements hook_field_is_empty(). */ function comment_field_is_empty($item, $field) { diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install index d641f34..69d329d 100644 --- a/core/modules/comment/comment.install +++ b/core/modules/comment/comment.install @@ -316,16 +316,15 @@ function comment_schema() { * Implements hook_field_schema(). */ function comment_field_schema($field) { - $columns = array( - 'comment' => array( - 'description' => 'Whether comments are allowed on this entity: 0 = no, 1 = closed (read only), 2 = open (read/write).', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ), - ); return array( - 'columns' => $columns, + 'columns' => array( + 'status' => array( + 'description' => 'Whether comments are allowed on this entity: 0 = no, 1 = closed (read only), 2 = open (read/write).', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + ), ); } @@ -458,7 +457,7 @@ function comment_update_8004() { } /** - * Updates the comment_node_statistics and comment tables to new structure. + * Updates the {comment_node_statistics} and {comment} tables to new structure. */ function comment_update_8005(&$sandbox) { // Drop old indexes. @@ -569,7 +568,7 @@ function comment_update_8006(&$sandbox) { // Add a default comment field for existing node comments. $field = array( 'cardinality' => '1', - // We need one per content type to match the existing bundles. + // We need one per content type to match the existing comment bundles. 'field_name' => 'comment_node_' . $node_type, 'module' => 'comment', 'settings' => array(), @@ -598,7 +597,7 @@ function comment_update_8006(&$sandbox) { ); $instance = array( 'bundle' => $node_type, - 'default_value' => array(array('comment' => $default_value)), + 'default_value' => array(array('status' => $default_value)), 'deleted' => '0', 'description' => '', 'entity_type' => 'node', @@ -643,7 +642,7 @@ function comment_update_8006(&$sandbox) { $display->set('content.' . $field['field_name'], $display_options_default) ->save(); update_config_manifest_add('entity.display', array($display->get('id'))); - +/* // Update all other entity displays with custom settings. $display_options = array( 'type' => 'hidden', @@ -657,7 +656,7 @@ function comment_update_8006(&$sandbox) { ->save(); update_config_manifest_add('entity.display', array($display->get('id'))); } - } + }*/ // Clean up old variables. variable_del('comment_' . $node_type); @@ -714,7 +713,7 @@ function comment_update_8007(&$sandbox) { 'revision_id', 'langcode', 'delta', - 'comment_node_' . $sandbox['node_type'] . '_comment', + 'comment_node_' . $sandbox['node_type'] . '_status', )); $revision = db_insert('field_revision_comment_node_' . $sandbox['node_type']) ->fields(array( @@ -724,7 +723,7 @@ function comment_update_8007(&$sandbox) { 'revision_id', 'langcode', 'delta', - 'comment_node_' . $sandbox['node_type'] . '_comment', + 'comment_node_' . $sandbox['node_type'] . '_status', )); // Update the field name to match the node type. @@ -740,24 +739,31 @@ function comment_update_8007(&$sandbox) { 'bundle' => $sandbox['node_type'], 'entity_id' => $nid, 'revision_id' => $node->vid, - 'langcode' => $node->langcode, + 'langcode' => LANGUAGE_NOT_SPECIFIED, 'delta' => 0, - 'comment_node_' . $sandbox['node_type'] . '_comment' => $node->comment, + 'comment_node_' . $sandbox['node_type'] . '_status' => $node->comment, )); $revision->values(array( 'entity_type' => 'node', 'bundle' => $sandbox['node_type'], 'entity_id' => $nid, 'revision_id' => $node->vid, - 'langcode' => $node->langcode, + 'langcode' => LANGUAGE_NOT_SPECIFIED, 'delta' => 0, - 'comment_node_' . $sandbox['node_type'] . '_comment' => $node->comment, + 'comment_node_' . $sandbox['node_type'] . '_status' => $node->comment, )); $sandbox['progress']++; $sandbox['current_nid'] = $nid; } $insert->execute(); $revision->execute(); + // Populate the field name to match the node type. + db_update('comment_entity_statistics') + ->fields(array( + 'field_name' => 'comment_node_' . $sandbox['node_type'], + )) + ->condition('entity_id', array_keys($nodes)) + ->execute(); } else { // Move to the next node type. diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index e2e10be..05f5caa 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -130,14 +130,12 @@ function comment_entity_view(EntityInterface $entity, EntityDisplay $display, $v $fields = field_info_instances($entity->entityType(), $entity->bundle()); foreach ($fields as $field_name => $instance) { $links = array(); - $field = field_info_field($instance['field_name']); + $field = field_info_field($field_name); if ($field['type'] != 'comment') { continue; } $values = field_get_items($entity, $field_name); - if ($values && is_array($values) && ($value = reset($values)) && - !empty($value['comment']) && - $value['comment'] != COMMENT_HIDDEN) { + if (isset($values[0]['status']) && !empty($values[0]['status']) && $values[0]['status'] != COMMENT_HIDDEN) { $uri = $entity->uri(); if ($view_mode == 'rss') { // Add a comments RSS element which is a URL to the comments of this node. @@ -178,7 +176,7 @@ function comment_entity_view(EntityInterface $entity, EntityDisplay $display, $v } $values = field_get_items($entity, $field_name); $value = reset($values); - if (!empty($value['comment']) && $value['comment'] == COMMENT_OPEN) { + if (!empty($value['status']) && $value['status'] == COMMENT_OPEN) { $comment_form_location = $instance['settings']['comment']['comment_form_location']; if (user_access('post comments')) { $links['comment-add'] = array( @@ -963,7 +961,7 @@ function comment_view(Comment $comment, $view_mode = 'full', $langcode = NULL) { function comment_links(Comment $comment, EntityInterface $entity, $field_name) { $links = array(); $items = field_get_items($entity, $field_name); - $status = isset($items[0]['comment']) ? $items[0]['comment'] : COMMENT_OPEN; + $status = isset($items[0]['status']) ? $items[0]['status'] : COMMENT_OPEN; if ($status == COMMENT_OPEN) { if (user_access('administer comments') && user_access('post comments')) { $links['comment-delete'] = array( @@ -1215,8 +1213,8 @@ function comment_node_update_index(Node $node, $langcode) { $mode = $instance['settings']['comment']['comment_default_mode']; $comments_per_page = $instance['settings']['comment']['comment_default_per_page']; if (($items = field_get_items($node, $field_name)) && - isset($items[0]['comment']) && - $items[0]['comment'] && $cids = comment_get_thread($node, $field_name, $mode, $comments_per_page)) { + isset($items[0]['status']) && + $items[0]['status'] && $cids = comment_get_thread($node, $field_name, $mode, $comments_per_page)) { $comments = comment_load_multiple($cids); comment_prepare_thread($comments); $build = comment_view_multiple($comments); @@ -1249,8 +1247,8 @@ function comment_node_search_result($node) { foreach ($comment_fields as $field_name => $info) { // Do not make a string if comments are hidden. if (user_access('access comments') && ($items = field_get_items($node, $field_name)) && - isset($items[0]['comment']) && $items[0]['comment'] != COMMENT_HIDDEN) { - if ($items[0]['comment'] == COMMENT_OPEN) { + isset($items[0]['status']) && $items[0]['status'] != COMMENT_HIDDEN) { + if ($items[0]['status'] == COMMENT_OPEN) { // At least one comment field is open. $open = TRUE; } @@ -1576,7 +1574,7 @@ function comment_preview(Comment $comment) { // loop. $values = $entity->{$comment->field_name->value}; $entity->{$comment->field_name->value} = array( - field_language($entity, $comment->field_name->value) => array(array('comment' => COMMENT_HIDDEN)), + field_language($entity, $comment->field_name->value) => array(array('status' => COMMENT_HIDDEN)), ); $build = entity_view($entity, 'full'); $entity->{$comment->field_name->value} = $values; @@ -2103,9 +2101,11 @@ function comment_library_info() { * are attached on a certain entity type. Defaults to NULL. * * @return array - * An array of comment field definitions, keyed by field name. Each field has - * an additional property, 'bundles', which is an array of all the bundles to - * which this field belongs, keyed by entity type. + * An array of comment field map definitions, keyed by field name. Each value + * is an array with two entries: + * - type: The field type. + * - bundles: The bundles in which the field appears, as an array with entity + * types as keys and the array of bundle names as values. * * @see field_info_fields(). */ @@ -2179,6 +2179,7 @@ function comment_add_default_comment_field($entity_type, $bundle, $field_name = $field = array( 'field_name' => $field_name, 'type' => 'comment', + 'translatable' => '0', ); // Create the field. field_create_field($field); @@ -2192,36 +2193,11 @@ function comment_add_default_comment_field($entity_type, $bundle, $field_name = 'entity_type' => $entity_type, 'bundle' => $bundle, 'required' => 1, - 'default_value' => array(array('comment' => $default_value)), + 'default_value' => array(array('status' => $default_value)), 'widget' => array( 'type' => 'comment_default', 'weight' => '50', ), - 'display' => array( - 'default' => array( - 'label' => 'hidden', - 'module' => 'comment', - 'settings' => array(), - 'type' => 'comment_default', - 'weight' => '1', - ), - 'rss' => array( - 'type' => 'hidden', - 'label' => 'hidden', - ), - 'teaser' => array( - 'type' => 'hidden', - 'label' => 'hidden', - ), - 'search_index' => array( - 'type' => 'hidden', - 'label' => 'hidden', - ), - 'search_result' => array( - 'type' => 'hidden', - 'label' => 'hidden', - ) - ), ); field_create_instance($instance); diff --git a/core/modules/comment/comment.pages.inc b/core/modules/comment/comment.pages.inc index e85127b..30455d5 100644 --- a/core/modules/comment/comment.pages.inc +++ b/core/modules/comment/comment.pages.inc @@ -96,7 +96,7 @@ function comment_reply(EntityInterface $entity, $field_name, $pid = NULL) { // We make sure the field value isn't set so we don't end up with a redirect loop. $original = $entity->{$field_name}; $entity->{$field_name} = array( - field_language($entity, $field_name) => array(array('comment' => COMMENT_HIDDEN)), + field_language($entity, $field_name) => array(array('status' => COMMENT_HIDDEN)), ); $build['comment_entity'] = entity_view($entity, 'full'); $entity->{$field_name} = $original; @@ -104,7 +104,7 @@ function comment_reply(EntityInterface $entity, $field_name, $pid = NULL) { // Should we show the reply box? $items = field_get_items($entity, $field_name); - $status = isset($items[0]['comment']) ? $items[0]['comment'] : COMMENT_OPEN; + $status = isset($items[0]['status']) ? $items[0]['status'] : COMMENT_OPEN; if ($status != COMMENT_OPEN) { drupal_set_message(t("This discussion is closed: you can't post new comments."), 'error'); drupal_goto($uri['path']); diff --git a/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php index 5cf817e..35a27e5 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentFormController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php @@ -320,7 +320,7 @@ public function save(array $form, array &$form_state) { $status = reset($items); $uri = $entity->uri(); - if (user_access('post comments') && (user_access('administer comments') || $status['comment'] == COMMENT_OPEN)) { + if (user_access('post comments') && (user_access('administer comments') || $status['status'] == COMMENT_OPEN)) { // Save the anonymous user information to a cookie for reuse. if (user_is_anonymous()) { user_cookie_save(array_intersect_key($form_state['values'], array_flip(array('name', 'mail', 'homepage')))); diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/field/formatter/CommentDefaultFormatter.php b/core/modules/comment/lib/Drupal/comment/Plugin/field/formatter/CommentDefaultFormatter.php index 1ef308e..798d421 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/field/formatter/CommentDefaultFormatter.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/field/formatter/CommentDefaultFormatter.php @@ -33,10 +33,8 @@ public function viewElements(EntityInterface $entity, $langcode, array $items) { $elements = array(); $field = $this->field; - // We only ever process first value. - // @todo Alter default field instance settings to - // disallow select more then 1 value cardinality. - $commenting_status = isset($items[0]['comment']) ? $items[0]['comment'] : COMMENT_OPEN; + // We only ever process first value if any. + $commenting_status = isset($items[0]['status']) ? $items[0]['status'] : COMMENT_OPEN; if ($commenting_status != COMMENT_HIDDEN && empty($entity->in_preview)) { $comment_settings = $this->instance['settings']['comment']; diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/field/widget/CommentWidget.php b/core/modules/comment/lib/Drupal/comment/Plugin/field/widget/CommentWidget.php index da1f43f..32af0d6 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/field/widget/CommentWidget.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/field/widget/CommentWidget.php @@ -31,15 +31,12 @@ class CommentWidget extends WidgetBase { public function formElement(array $items, $delta, array $element, $langcode, array &$form, array &$form_state) { $field = $this->field; $entity = $element['#entity']; - $default_value = isset($items[0]['comment']) ? $items[0]['comment'] : COMMENT_OPEN; - $comment_count = empty($entity->comment_statistics[$field['field_name']]->comment_count) ? 0 : $entity->comment_statistics[$field['field_name']]->comment_count; - $commenting_enabled = ($default_value == COMMENT_HIDDEN && empty($comment_count)) ? COMMENT_CLOSED : $default_value; - $element['comment'] = array( + $element['status'] = array( '#type' => 'radios', '#title' => t('Comments'), '#title_display' => 'invisible', - '#default_value' => $commenting_enabled, + '#default_value' => isset($items[0]['status']) ? $items[0]['status'] : COMMENT_OPEN, '#options' => array( COMMENT_OPEN => t('Open'), COMMENT_CLOSED => t('Closed'), @@ -55,22 +52,21 @@ public function formElement(array $items, $delta, array $element, $langcode, arr '#description' => t('Comments are hidden from view.'), ), ); - // If the node doesn't have any comments, the "hidden" option makes no - // sense, so don't even bother presenting it to the user. - if (empty($comment_count)) { - $element['comment'][COMMENT_HIDDEN]['#access'] = FALSE; + // If used for the field settings form or the entity doesn't have any + // comments, the "hidden" option makes no sense, so don't even bother + // presenting it to the user. + if (!empty($entity->field_ui_default_value) || empty($entity->comment_statistics[$field['field_name']]->comment_count)) { + $element['status'][COMMENT_HIDDEN]['#access'] = FALSE; // Also adjust the description of the "closed" option. - $element['comment'][COMMENT_CLOSED]['#description'] = t('Users cannot post comments.'); + $element['status'][COMMENT_CLOSED]['#description'] = t('Users cannot post comments.'); } // Integrate with advanced settings, if available. if (isset($form['advanced'])) { $element += array( '#type' => 'details', '#group' => 'advanced', - '#access' => user_access('administer comments'), - '#collapsed' => TRUE, '#attributes' => array( - 'class' => array('comment-node-settings-form'), + 'class' => array('comment-' . $element['#entity_type'] . '-settings-form'), ), '#attached' => array( 'library' => array('comment', 'drupal.comment'), diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php index e5ca92f..68980cd 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentCSSTest.php @@ -45,7 +45,7 @@ function testCommentClasses() { foreach ($permutations as $case) { // Create a new node. - $node = $this->drupalCreateNode(array('type' => 'article', 'uid' => $case['node_uid'], 'comment' => array(LANGUAGE_NOT_SPECIFIED => array(array('comment' => COMMENT_OPEN))))); + $node = $this->drupalCreateNode(array('type' => 'article', 'uid' => $case['node_uid'])); // Add a comment. $comment = entity_create('comment', array( diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php index e4e5ada..422609b 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php @@ -83,7 +83,7 @@ function testCommentEnable() { comment_add_default_comment_field('node', 'book'); $book_node = $this->drupalCreateNode(array( 'type' => 'book', - 'comment' => array(LANGUAGE_NOT_SPECIFIED => array(array('comment' => COMMENT_OPEN))) + 'comment' => array(LANGUAGE_NOT_SPECIFIED => array(array('status' => COMMENT_OPEN))) )); $this->drupalLogout(); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php index 41ecb1d..f2e734f 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php @@ -140,21 +140,21 @@ function testCommentInterface() { $this->assertText(t('The comment you are replying to does not exist.'), 'Replying to an unpublished comment'); // Attempt to post to node with comments disabled. - $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(LANGUAGE_NOT_SPECIFIED => array(array('comment' => COMMENT_HIDDEN))))); + $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(LANGUAGE_NOT_SPECIFIED => array(array('status' => COMMENT_HIDDEN))))); $this->assertTrue($this->node, 'Article node created.'); $this->drupalGet('comment/reply/node/' . $this->node->nid . '/comment'); $this->assertText('This discussion is closed', 'Posting to node with comments disabled'); $this->assertNoField('edit-comment', 'Comment body field found.'); // Attempt to post to node with read-only comments. - $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(LANGUAGE_NOT_SPECIFIED => array(array('comment' => COMMENT_CLOSED))))); + $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(LANGUAGE_NOT_SPECIFIED => array(array('status' => COMMENT_CLOSED))))); $this->assertTrue($this->node, 'Article node created.'); $this->drupalGet('comment/reply/node/' . $this->node->nid . '/comment'); $this->assertText('This discussion is closed', 'Posting to node with comments read-only'); $this->assertNoField('edit-comment', 'Comment body field found.'); // Attempt to post to node with comments enabled (check field names etc). - $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(LANGUAGE_NOT_SPECIFIED => array(array('comment' => COMMENT_OPEN))))); + $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(LANGUAGE_NOT_SPECIFIED => array(array('status' => COMMENT_OPEN))))); $this->assertTrue($this->node, 'Article node created.'); $this->drupalGet('comment/reply/node/' . $this->node->nid . '/comment'); $this->assertNoText('This discussion is closed', 'Posting to node with comments enabled'); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php index f7e5ee5..7ac6ed6 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php @@ -156,8 +156,8 @@ function setEnvironment(array $info) { // Change comment settings. $this->setCommentSettings('comment_form_location', $info['form'], 'Set comment form location'); $this->setCommentAnonymous($info['contact']); - if ($this->node->comment[LANGUAGE_NOT_SPECIFIED][0]['comment'] != $info['comments']) { - $this->node->comment[LANGUAGE_NOT_SPECIFIED][0]['comment'] = $info['comments']; + if ($this->node->comment[LANGUAGE_NOT_SPECIFIED][0]['status'] != $info['comments']) { + $this->node->comment[LANGUAGE_NOT_SPECIFIED][0]['status'] = $info['comments']; node_save($this->node); } diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentPagerTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentPagerTest.php index 661c83e..55e7b54 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentPagerTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentPagerTest.php @@ -31,7 +31,7 @@ function testCommentPaging() { $this->setCommentPreview(DRUPAL_DISABLED); // Create a node and three comments. - $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(LANGUAGE_NOT_SPECIFIED => array(array('comment' => COMMENT_OPEN))))); + $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1)); $comments = array(); $comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE); $comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE); @@ -106,7 +106,7 @@ function testCommentOrderingThreading() { $this->setCommentsPerPage(1000); // Create a node and three comments. - $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(LANGUAGE_NOT_SPECIFIED => array(array('comment' => COMMENT_OPEN))))); + $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1)); $comments = array(); $comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE); $comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE); @@ -206,7 +206,7 @@ function testCommentNewPageIndicator() { $this->setCommentsPerPage(1); // Create a node and three comments. - $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => array(LANGUAGE_NOT_SPECIFIED => array(array('comment' => COMMENT_OPEN))))); + $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1)); $comments = array(); $comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE); $comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentRssTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentRssTest.php index 5a91b74..bf95c71 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentRssTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentRssTest.php @@ -31,7 +31,7 @@ function testCommentRss() { $this->assertRaw($raw, 'Comments as part of RSS feed.'); // Hide comments from RSS feed and check presence. - $this->node->comment = array(LANGUAGE_NOT_SPECIFIED => array(array('comment' => COMMENT_HIDDEN))); + $this->node->comment = array(LANGUAGE_NOT_SPECIFIED => array(array('status' => COMMENT_HIDDEN))); node_save($this->node); $this->drupalGet('rss.xml'); $this->assertNoRaw($raw, 'Hidden comments is not a part of RSS feed.'); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php index c15c018..c11d2d4 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php @@ -76,7 +76,7 @@ function setUp() { comment_add_default_comment_field('node', 'article'); // Create a test node authored by the web user. - $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->web_user->uid, 'comment' => array(LANGUAGE_NOT_SPECIFIED => array(array('comment' => COMMENT_OPEN))))); + $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->web_user->uid)); } /** diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php index b8dd07a..27d5fb3 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php @@ -34,7 +34,7 @@ function testCommentThreading() { // Create a node. $this->drupalLogin($this->web_user); - $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->web_user->uid, 'comment' => array(LANGUAGE_NOT_SPECIFIED => array(array('comment' => COMMENT_OPEN))))); + $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'uid' => $this->web_user->uid)); // Post comment #1. $this->drupalLogin($this->web_user); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php index 59c3119..8392a10 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php @@ -35,7 +35,7 @@ function testCommentTokenReplacement() { $this->setCommentSubject(TRUE); // Create a node and a comment. - $node = $this->drupalCreateNode(array('type' => 'article', 'comment' => array(LANGUAGE_NOT_SPECIFIED => array(array('comment' => COMMENT_OPEN))))); + $node = $this->drupalCreateNode(array('type' => 'article')); $parent_comment = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE); // Post a reply to the comment. diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentUserTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentUserTest.php index f8dc15c..54aeedb 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentUserTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentUserTest.php @@ -84,9 +84,6 @@ function setUp() { 'post comments', 'skip comment approval', )); - - $this->web_user->comment = array(LANGUAGE_NOT_SPECIFIED => array(array('comment' => COMMENT_OPEN))); - $this->web_user->save(); } /** @@ -321,8 +318,8 @@ function testCommentUser() { drupal_flush_all_caches(); $this->drupalGet('user/' . $this->web_user->uid); $this->assertPattern('@]*>Comments@', 'Comments were displayed.'); - $this->assertLink('Log in', 1, 'Link to log in was found.'); - $this->assertLink('register', 1, 'Link to register was found.'); + $this->assertLink('Log in', 0, 'Link to log in was found.'); + $this->assertLink('register', 0, 'Link to register was found.'); user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array( 'access comments' => FALSE, diff --git a/core/modules/comment/lib/Drupal/comment/Tests/Views/CommentTestBase.php b/core/modules/comment/lib/Drupal/comment/Tests/Views/CommentTestBase.php index e6f277e..58d72a0 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/Views/CommentTestBase.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/Views/CommentTestBase.php @@ -44,13 +44,13 @@ function setUp() { $this->node_user_posted = $this->drupalCreateNode(array( 'comment' => array( - LANGUAGE_NOT_SPECIFIED => array(array('comment' => COMMENT_OPEN)) + LANGUAGE_NOT_SPECIFIED => array(array('status' => COMMENT_OPEN)) ), )); $this->node_user_commented = $this->drupalCreateNode(array( 'uid' => $this->account2->uid, 'comment' => array( - LANGUAGE_NOT_SPECIFIED => array(array('comment' => COMMENT_OPEN)) + LANGUAGE_NOT_SPECIFIED => array(array('status' => COMMENT_OPEN)) ), )); diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index d8e221e..875a971 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -244,7 +244,7 @@ protected function drupalCreateNode(array $settings = array()) { if (module_exists('comment')) { $settings += array( 'comment' => array(LANGUAGE_NOT_SPECIFIED => array( - array('comment' => COMMENT_OPEN) + array('status' => COMMENT_OPEN) )), ); }