diff --git a/core/modules/comment/comment.field.inc b/core/modules/comment/comment.field.inc index 9e7b7dd..abef815 100644 --- a/core/modules/comment/comment.field.inc +++ b/core/modules/comment/comment.field.inc @@ -19,17 +19,15 @@ function comment_field_info() { 'description' => t('This field manages configuration and presentation of comments on an entity'), 'settings' => array(), 'instance_settings' => array( - 'comment' => array( - // Save this settings to allow other modules to migrate their data. - // The "comment_default" formatter settings are used instead. - 'comment_default_mode' => COMMENT_MODE_THREADED, - 'comment_default_per_page' => 50, - 'comment_form_location' => COMMENT_FORM_BELOW, - // Comment form settings per field bundle. - 'comment_anonymous' => COMMENT_ANONYMOUS_MAYNOT_CONTACT, - 'comment_subject_field' => 1, - 'comment_preview' => DRUPAL_OPTIONAL - ) + // Save this settings to allow other modules to migrate their data. + // @todo The "comment_default" formatter settings should used instead. + 'default_mode' => COMMENT_MODE_THREADED, + 'per_page' => 50, + 'form_location' => COMMENT_FORM_BELOW, + // Comment form settings per field bundle. + 'anonymous' => COMMENT_ANONYMOUS_MAYNOT_CONTACT, + 'subject' => 1, + 'preview' => DRUPAL_OPTIONAL, ), 'default_widget' => 'comment_default', 'default_formatter' => 'comment_default' @@ -41,14 +39,14 @@ function comment_field_info() { * Implements hook_field_instance_settings_form(). */ function comment_field_instance_settings_form($field, $instance) { - $settings = $instance['settings']['comment']; + $settings = $instance['settings']; $form['comment'] = array( '#type' => 'details', '#title' => t('Comment form settings'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#field_name' => $field['field_name'], - '#process' => array('comment_instance_settings_translation_entity_process'), + '#process' => array('_comment_field_instance_settings_form_process'), '#attributes' => array( 'class' => array('comment-instance-settings-form'), ), @@ -56,22 +54,22 @@ function comment_field_instance_settings_form($field, $instance) { 'library' => array(array('comment', 'drupal.comment')), ), ); - $form['comment']['comment_default_mode'] = array( + $form['comment']['default_mode'] = array( '#type' => 'checkbox', '#title' => t('Threading'), - '#default_value' => $settings['comment_default_mode'], + '#default_value' => $settings['default_mode'], '#description' => t('Show comment replies in a threaded list.'), ); - $form['comment']['comment_default_per_page'] = array( + $form['comment']['per_page'] = array( '#type' => 'select', '#title' => t('Comments per page'), - '#default_value' => $settings['comment_default_per_page'], + '#default_value' => $settings['per_page'], '#options' => _comment_per_page(), ); - $form['comment']['comment_anonymous'] = array( + $form['comment']['anonymous'] = array( '#type' => 'select', '#title' => t('Anonymous commenting'), - '#default_value' => $settings['comment_anonymous'], + '#default_value' => $settings['anonymous'], '#options' => array( COMMENT_ANONYMOUS_MAYNOT_CONTACT => t('Anonymous posters may not enter their contact information'), COMMENT_ANONYMOUS_MAY_CONTACT => t('Anonymous posters may leave their contact information'), @@ -79,20 +77,20 @@ function comment_field_instance_settings_form($field, $instance) { ), '#access' => user_access('post comments', drupal_anonymous_user()), ); - $form['comment']['comment_subject_field'] = array( + $form['comment']['subject'] = array( '#type' => 'checkbox', '#title' => t('Allow comment title'), - '#default_value' => $settings['comment_subject_field'], + '#default_value' => $settings['subject'], ); - $form['comment']['comment_form_location'] = array( + $form['comment']['form_location'] = array( '#type' => 'checkbox', '#title' => t('Show reply form on the same page as comments'), - '#default_value' => $settings['comment_form_location'], + '#default_value' => $settings['form_location'], ); - $form['comment']['comment_preview'] = array( + $form['comment']['preview'] = array( '#type' => 'radios', '#title' => t('Preview comment'), - '#default_value' => $settings['comment_preview'], + '#default_value' => $settings['preview'], '#options' => array( DRUPAL_DISABLED => t('Disabled'), DRUPAL_OPTIONAL => t('Optional'), @@ -108,8 +106,13 @@ function comment_field_instance_settings_form($field, $instance) { * Attaches the required translation entity handlers for the instance which * correlates one to one with the comment bundle. */ -function comment_instance_settings_translation_entity_process($element, $form_state) { - if (module_exists('translation_entity')) { +function _comment_field_instance_settings_form_process($element, $form_state) { + // Settings should not be stored as nested. + $parents = $element['#parents']; + array_pop($parents); + $element['#parents'] = $parents; + // Add translation entity handlers. + if (drupal_container()->get('module_handler')->moduleExists('translation_entity')) { $comment_form = $element; $comment_form_state['translation_entity']['key'] = 'language_configuration'; $element += translation_entity_enable_widget('comment', $element['#field_name'], $comment_form, $comment_form_state); diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install index 426f093..f9678a2 100644 --- a/core/modules/comment/comment.install +++ b/core/modules/comment/comment.install @@ -553,8 +553,8 @@ function comment_update_8005(&$sandbox) { /** * Adds comment fields for all node types. * - * Field instance settings "comment_default_mode", "comment_default_per_page" - * and "comment_form_location" are preserved to allow migrate contrib modules. + * Field instance settings "default_mode", "per_page" and "form_location" are + * preserved to allow migrate contrib modules. */ function comment_update_8006(&$sandbox) { // Loop over defined node_types. @@ -582,15 +582,15 @@ function comment_update_8006(&$sandbox) { // the given node_type. $instance_settings = array( // COMMENT_MODE_THREADED - 'comment_default_mode' => variable_get('comment_default_mode_' . $node_type, 1), - 'comment_default_per_page' => variable_get('comment_default_per_page_' . $node_type, 50), + 'default_mode' => variable_get('comment_default_mode_' . $node_type, 1), + 'per_page' => variable_get('comment_default_per_page_' . $node_type, 50), // COMMENT_FORM_BELOW - 'comment_form_location' => variable_get('comment_form_location' . $node_type, 1), + 'form_location' => variable_get('comment_form_location' . $node_type, 1), // COMMENT_ANONYMOUS_MAYNOT_CONTACT - 'comment_anonymous' => variable_get('comment_anonymous_' . $node_type, 0), - 'comment_subject_field' => variable_get('comment_subject_field_' . $node_type, 1), + 'anonymous' => variable_get('comment_anonymous_' . $node_type, 0), + 'subject' => variable_get('comment_subject_field_' . $node_type, 1), // DRUPAL_OPTIONAL - 'comment_preview' => variable_get('comment_preview_' . $node_type, 1), + 'preview' => variable_get('comment_preview_' . $node_type, 1), ); $instance = array( 'bundle' => $node_type, @@ -601,9 +601,7 @@ function comment_update_8006(&$sandbox) { 'field_name' => $field['field_name'], 'label' => 'Comment settings', 'required' => 1, - 'settings' => array( - 'comment' => $instance_settings, - ), + 'settings' => $instance_settings, 'widget' => array( 'active' => 0, 'module' => 'comment', diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 2ee2851..1aeda05 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -183,7 +183,7 @@ function comment_entity_view(EntityInterface $entity, EntityDisplay $display, $v } // Provide a link to new comment form. if ($commenting_status == COMMENT_OPEN) { - $comment_form_location = $instance['settings']['comment']['comment_form_location']; + $comment_form_location = $instance['settings']['form_location']; if (user_access('post comments')) { $links['comment-add'] = array( 'title' => t('Add new comment'), @@ -209,7 +209,7 @@ function comment_entity_view(EntityInterface $entity, EntityDisplay $display, $v // But we don't want this link if we're building the entity for search // indexing or constructing a search result excerpt. if ($commenting_status == COMMENT_OPEN) { - $comment_form_location = $instance['settings']['comment']['comment_form_location']; + $comment_form_location = $instance['settings']['form_location']; if (user_access('post comments')) { // Show the "post comment" link if the form is on another page, or // if there are existing comments that the link will skip past. @@ -663,8 +663,8 @@ function comment_get_recent($number = 10) { */ function comment_new_page_count($num_comments, $new_replies, EntityInterface $entity, $field_name = 'comment') { $instance = field_info_instance($entity->entityType(), $field_name, $entity->bundle()); - $mode = $instance['settings']['comment']['comment_default_mode']; - $comments_per_page = $instance['settings']['comment']['comment_default_per_page']; + $mode = $instance['settings']['default_mode']; + $comments_per_page = $instance['settings']['per_page']; $pagenum = NULL; $flat = $mode == COMMENT_MODE_FLAT ? TRUE : FALSE; if ($num_comments <= $comments_per_page) { @@ -1207,8 +1207,8 @@ function comment_node_update_index(Node $node, $langcode) { if ($index_comments) { foreach (comment_get_comment_fields('node') as $field_name => $info) { $instance = field_info_instance('node', $field_name, $node->type); - $mode = $instance['settings']['comment']['comment_default_mode']; - $comments_per_page = $instance['settings']['comment']['comment_default_per_page']; + $mode = $instance['settings']['default_mode']; + $comments_per_page = $instance['settings']['per_page']; if (($items = field_get_items($node, $field_name)) && _comment_get_default_status($items) && $cids = comment_get_thread($node, $field_name, $mode, $comments_per_page)) { $comments = comment_load_multiple($cids); @@ -1471,7 +1471,7 @@ function comment_get_display_ordinal($cid, $instance) { if (!user_access('administer comments')) { $query->condition('c1.status', COMMENT_PUBLISHED); } - $mode = $instance['settings']['comment']['comment_default_mode']; + $mode = $instance['settings']['default_mode']; if ($mode == COMMENT_MODE_FLAT) { // For flat comments, cid is used for ordering comments due to @@ -1505,7 +1505,7 @@ function comment_get_display_ordinal($cid, $instance) { */ function comment_get_display_page($cid, $instance) { $ordinal = comment_get_display_ordinal($cid, $instance); - $comments_per_page = $instance['settings']['comment']['comment_default_per_page']; + $comments_per_page = $instance['settings']['per_page']; return floor($ordinal / $comments_per_page); } @@ -1753,7 +1753,7 @@ function theme_comment_post_forbidden($variables) { if ($authenticated_post_comments) { // We cannot use drupal_get_destination() because these links // sometimes appear on /node and taxonomy listing pages. - if ($instance['settings']['comment']['comment_form_location'] == COMMENT_FORM_SEPARATE_PAGE) { + if ($instance['settings']['form_location'] == COMMENT_FORM_SEPARATE_PAGE) { $destination = array('destination' => 'comment/reply/' . $entity->entityType() . '/' . $entity->id() . '/' . $field_name .'#comment-form'); } else { diff --git a/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php index e255eb0..61c16c0 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentFormController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php @@ -29,7 +29,7 @@ public function form(array $form, array &$form_state, EntityInterface $comment) $form['#id'] = drupal_html_id('comment_form'); $form['#theme'] = array('comment_form__' . $comment->entity_type->value . '__' . $entity->bundle() . '__' . $comment->field_name->value, 'comment_form'); - $anonymous_contact = $instance['settings']['comment']['comment_anonymous']; + $anonymous_contact = $instance['settings']['anonymous']; $is_admin = ($comment->id() && user_access('administer comments')); if (!$user->uid && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT) { @@ -142,7 +142,7 @@ public function form(array $form, array &$form_state, EntityInterface $comment) '#title' => t('Subject'), '#maxlength' => 64, '#default_value' => $comment->subject->value, - '#access' => $instance['settings']['comment']['comment_subject_field'], + '#access' => $instance['settings']['subject'], ); // Used for conditional validation of author fields. @@ -175,7 +175,7 @@ protected function actions(array $form, array &$form_state) { $comment = $this->getEntity($form_state); $entity = entity_load($comment->entity_type->value, $comment->entity_id->target_id); $instance = field_info_instance($comment->entity_type->value, $comment->field_name->value, $entity->bundle()); - $preview_mode = $instance['settings']['comment']['comment_preview']; + $preview_mode = $instance['settings']['preview']; // No delete action on the comment form. unset($element['delete']); diff --git a/core/modules/comment/lib/Drupal/comment/CommentRenderController.php b/core/modules/comment/lib/Drupal/comment/CommentRenderController.php index 2707c1a..5e7d2ed 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentRenderController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentRenderController.php @@ -85,7 +85,7 @@ protected function alterBuild(array &$build, EntityInterface $comment, EntityDis $comment_entity = entity_load($comment->entity_type->value, $comment->entity_id->target_id); $instance = field_info_instance($comment_entity->entityType(), $comment->field_name->value, $comment_entity->bundle()); $is_threaded = isset($comment->divs) - && $instance['settings']['comment']['comment_default_mode'] == COMMENT_MODE_THREADED; + && $instance['settings']['default_mode'] == COMMENT_MODE_THREADED; // Add 'new' anchor if needed. if (!empty($comment->first_new)) { 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 e470a01..fa86005 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 @@ -36,7 +36,7 @@ public function viewElements(EntityInterface $entity, $langcode, array $items) { $commenting_status = _comment_get_default_status($items); if ($commenting_status != COMMENT_HIDDEN && empty($entity->in_preview)) { - $comment_settings = $this->instance['settings']['comment']; + $comment_settings = $this->instance['settings']; // Only attempt to render comments if the entity has visible comments. // Unpublished comments are not included in @@ -48,8 +48,8 @@ public function viewElements(EntityInterface $entity, $langcode, array $items) { // Comment threads aren't added to search results/indexes using the // formatter, @see comment_node_update_index(). - $mode = $comment_settings['comment_default_mode']; - $comments_per_page = $comment_settings['comment_default_per_page']; + $mode = $comment_settings['default_mode']; + $comments_per_page = $comment_settings['per_page']; if ($cids = comment_get_thread($entity, $field['field_name'], $mode, $comments_per_page)) { $comments = comment_load_multiple($cids); comment_prepare_thread($comments); @@ -60,7 +60,7 @@ public function viewElements(EntityInterface $entity, $langcode, array $items) { } // Append comment form if needed. - if ($commenting_status == COMMENT_OPEN && $comment_settings['comment_form_location'] == COMMENT_FORM_BELOW) { + if ($commenting_status == COMMENT_OPEN && $comment_settings['form_location'] == COMMENT_FORM_BELOW) { // Only show the add comment form if the user has permission and the // view mode is not search_result or search_index. if (user_access('post comments') && !empty($entity->content['#view_mode']) && @@ -74,7 +74,7 @@ public function viewElements(EntityInterface $entity, $langcode, array $items) { $elements[] = $additions + array( '#theme' => 'comment_wrapper__' . $entity->entityType() . '__' . $entity->bundle() . '__' . $field['field_name'], '#entity' => $entity, - '#display_mode' => $this->instance['settings']['comment']['comment_default_mode'], + '#display_mode' => $this->instance['settings']['default_mode'], 'comments' => array(), 'comment_form' => array(), ); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php index f2e734f..4607c0b 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php @@ -30,7 +30,7 @@ function testCommentInterface() { $this->setCommentPreview(DRUPAL_DISABLED); $this->setCommentForm(TRUE); $this->setCommentSubject(FALSE); - $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.'); + $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.'); $this->drupalLogout(); // Post comment #1 without subject or preview. diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php index 7ac6ed6..3ebe5265 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php @@ -154,7 +154,7 @@ function setEnvironment(array $info) { } // Change comment settings. - $this->setCommentSettings('comment_form_location', $info['form'], 'Set comment form location'); + $this->setCommentSettings('form_location', $info['form'], 'Set comment form location'); $this->setCommentAnonymous($info['contact']); if ($this->node->comment[LANGUAGE_NOT_SPECIFIED][0]['status'] != $info['comments']) { $this->node->comment[LANGUAGE_NOT_SPECIFIED][0]['status'] = $info['comments']; diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentNodeAccessTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentNodeAccessTest.php index f8a8afd..d179300 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentNodeAccessTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentNodeAccessTest.php @@ -57,7 +57,7 @@ function testThreadedCommentView() { $this->setCommentPreview(DRUPAL_DISABLED); $this->setCommentForm(TRUE); $this->setCommentSubject(TRUE); - $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.'); + $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.'); $this->drupalLogout(); // Post comment. diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentPagerTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentPagerTest.php index 55e7b54..5c1550e 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentPagerTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentPagerTest.php @@ -37,7 +37,7 @@ function testCommentPaging() { $comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE); $comments[] = $this->postComment($node, $this->randomName(), $this->randomName(), TRUE); - $this->setCommentSettings('comment_default_mode', COMMENT_MODE_FLAT, 'Comment paging changed.'); + $this->setCommentSettings('default_mode', COMMENT_MODE_FLAT, 'Comment paging changed.'); // Set comments to one per page so that we are able to test paging without // needing to insert large numbers of comments. @@ -77,7 +77,7 @@ function testCommentPaging() { // If we switch to threaded mode, the replies on the oldest comment // should be bumped to the first page and comment 6 should be bumped // to the second page. - $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Switched to threaded mode.'); + $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, 'Switched to threaded mode.'); $this->drupalGet('node/' . $node->nid, array('query' => array('page' => 0))); $this->assertTrue($this->commentExists($reply, TRUE), 'In threaded mode, reply appears on page 1.'); $this->assertFalse($this->commentExists($comments[1]), 'In threaded mode, comment 2 has been bumped off of page 1.'); @@ -137,7 +137,7 @@ function testCommentOrderingThreading() { // - 2 // - 5 - $this->setCommentSettings('comment_default_mode', COMMENT_MODE_FLAT, 'Comment paging changed.'); + $this->setCommentSettings('default_mode', COMMENT_MODE_FLAT, 'Comment paging changed.'); $expected_order = array( 0, @@ -151,7 +151,7 @@ function testCommentOrderingThreading() { $this->drupalGet('node/' . $node->nid); $this->assertCommentOrder($comments, $expected_order); - $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Switched to threaded mode.'); + $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, 'Switched to threaded mode.'); $expected_order = array( 0, @@ -232,7 +232,7 @@ function testCommentNewPageIndicator() { // - 2 // - 5 - $this->setCommentSettings('comment_default_mode', COMMENT_MODE_FLAT, 'Comment paging changed.'); + $this->setCommentSettings('default_mode', COMMENT_MODE_FLAT, 'Comment paging changed.'); $expected_pages = array( 1 => 5, // Page of comment 5 @@ -250,7 +250,7 @@ function testCommentNewPageIndicator() { $this->assertIdentical($expected_page, $returned_page, format_string('Flat mode, @new replies: expected page @expected, returned page @returned.', array('@new' => $new_replies, '@expected' => $expected_page, '@returned' => $returned_page))); } - $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Switched to threaded mode.'); + $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, 'Switched to threaded mode.'); $expected_pages = array( 1 => 5, // Page of comment 5 diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php index faf6ace..c8980a7 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php @@ -40,7 +40,7 @@ function testCommentPreview() { $this->setCommentPreview(DRUPAL_OPTIONAL); $this->setCommentForm(TRUE); $this->setCommentSubject(TRUE); - $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.'); + $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.'); $this->drupalLogout(); // Login as web user and add a signature and a user picture. @@ -85,7 +85,7 @@ function testCommentEditPreviewSave() { $this->setCommentPreview(DRUPAL_OPTIONAL); $this->setCommentForm(TRUE); $this->setCommentSubject(TRUE); - $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.'); + $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.'); $edit = array(); $date = new DrupalDateTime('2008-03-02 17:23'); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentStatisticsTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentStatisticsTest.php index 77b5efd..d1cd4bb 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentStatisticsTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentStatisticsTest.php @@ -44,7 +44,7 @@ function testCommentNodeCommentStatistics() { $this->setCommentPreview(DRUPAL_DISABLED); $this->setCommentForm(TRUE); $this->setCommentSubject(FALSE); - $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.'); + $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.'); $this->drupalLogout(); // Checks the initial values of node comment statistics with no comment. diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php index c11d2d4..ccbcaaf 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php @@ -98,8 +98,8 @@ function postComment($node, $comment, $subject = '', $contact = NULL) { $edit['comment_body[' . $langcode . '][0][value]'] = $comment; $instance = field_info_instance('node', 'comment', 'article'); - $preview_mode = $instance['settings']['comment']['comment_preview']; - $subject_mode = $instance['settings']['comment']['comment_subject_field']; + $preview_mode = $instance['settings']['preview']; + $subject_mode = $instance['settings']['subject']; // Must get the page before we test for fields. if ($node !== NULL) { @@ -198,7 +198,7 @@ function deleteComment(Comment $comment) { * Boolean specifying whether the subject field should be enabled. */ function setCommentSubject($enabled) { - $this->setCommentSettings('comment_subject_field', ($enabled ? '1' : '0'), 'Comment subject ' . ($enabled ? 'enabled' : 'disabled') . '.'); + $this->setCommentSettings('subject', ($enabled ? '1' : '0'), 'Comment subject ' . ($enabled ? 'enabled' : 'disabled') . '.'); } /** @@ -221,7 +221,7 @@ function setCommentPreview($mode) { $mode_text = 'required'; break; } - $this->setCommentSettings('comment_preview', $mode, format_string('Comment preview @mode_text.', array('@mode_text' => $mode_text))); + $this->setCommentSettings('preview', $mode, format_string('Comment preview @mode_text.', array('@mode_text' => $mode_text))); } /** @@ -232,7 +232,7 @@ function setCommentPreview($mode) { * comments; FALSE if it should be displayed on its own page. */ function setCommentForm($enabled) { - $this->setCommentSettings('comment_form_location', ($enabled ? COMMENT_FORM_BELOW : COMMENT_FORM_SEPARATE_PAGE), 'Comment controls ' . ($enabled ? 'enabled' : 'disabled') . '.'); + $this->setCommentSettings('form_location', ($enabled ? COMMENT_FORM_BELOW : COMMENT_FORM_SEPARATE_PAGE), 'Comment controls ' . ($enabled ? 'enabled' : 'disabled') . '.'); } /** @@ -245,7 +245,7 @@ function setCommentForm($enabled) { * - 2: Contact information required. */ function setCommentAnonymous($level) { - $this->setCommentSettings('comment_anonymous', $level, format_string('Anonymous commenting set to level @level.', array('@level' => $level))); + $this->setCommentSettings('anonymous', $level, format_string('Anonymous commenting set to level @level.', array('@level' => $level))); } /** @@ -255,7 +255,7 @@ function setCommentAnonymous($level) { * Comments per page value. */ function setCommentsPerPage($number) { - $this->setCommentSettings('comment_default_per_page', $number, format_string('Number of comments per page set to @number.', array('@number' => $number))); + $this->setCommentSettings('per_page', $number, format_string('Number of comments per page set to @number.', array('@number' => $number))); } /** @@ -270,7 +270,7 @@ function setCommentsPerPage($number) { */ function setCommentSettings($name, $value, $message) { $instance = field_info_instance('node', 'comment', 'article'); - $instance['settings']['comment'][$name] = $value; + $instance['settings'][$name] = $value; field_update_instance($instance); // Display status message. $this->pass($message); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php index 27d5fb3..de4a9ca 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php @@ -29,7 +29,7 @@ function testCommentThreading() { $this->setCommentPreview(DRUPAL_DISABLED); $this->setCommentForm(TRUE); $this->setCommentSubject(TRUE); - $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.'); + $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, 'Comment paging changed.'); $this->drupalLogout(); // Create a node. diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentUserTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentUserTest.php index 2bd88aa..14b76e0 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentUserTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentUserTest.php @@ -105,8 +105,8 @@ function postComment($account, $comment, $subject = '', $contact = NULL) { $edit['comment_body[' . $langcode . '][0][value]'] = $comment; $instance = field_info_instance('user', 'comment', 'user'); - $preview_mode = $instance['settings']['comment']['comment_preview']; - $subject_mode = $instance['settings']['comment']['comment_subject_field']; + $preview_mode = $instance['settings']['preview']; + $subject_mode = $instance['settings']['subject']; // Must get the page before we test for fields. if ($account !== NULL) {