diff --git a/core/includes/update.inc b/core/includes/update.inc index 9dd8456..fbcd5c0 100644 --- a/core/includes/update.inc +++ b/core/includes/update.inc @@ -1045,7 +1045,7 @@ function update_variable_del($name) { * This would migrate the value contained in variable name 'old_variable' into * the data key 'new_config.sub_key' of the configuration object $config_name. */ -function update_variables_to_config($config_name, array $variable_map) { +function update_variables_to_config($config_name, array $variable_map, $default_config_name = NULL) { // Build the new configuration object. // This potentially loads an existing configuration object, in case another // update function migrated configuration values into $config_name already. @@ -1056,12 +1056,17 @@ function update_variables_to_config($config_name, array $variable_map) { $module = strtok($config_name, '.'); // Load and set default configuration values. - $file = new FileStorage(drupal_get_path('module', $module) . '/config'); - if (!$file->exists($config_name)) { + $file = new FileStorage(array('directory' => drupal_get_path('module', $module) . '/config')); + if ($file->exists($config_name)) { + $default_data = $file->read($config_name); + } + elseif ($default_config_name && $file->exists($default_config_name)) { + $default_data = $file->read($default_config_name); + } + else { throw new ConfigException("Default configuration file $config_name for $module extension not found but is required to exist."); } - $default_data = $file->read($config_name); - + // Merge any possibly existing original data into default values. // Only relevant when being called repetitively on the same config object. if (!empty($original_data)) { diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install index 0a147b5..6380669 100644 --- a/core/modules/comment/comment.install +++ b/core/modules/comment/comment.install @@ -13,19 +13,19 @@ function comment_uninstall() { field_delete_field('comment_body'); // Remove variables. - variable_del('comment_block_count'); + config('comment.settings')->clear('comment_block_count'); $node_types = array_keys(node_type_get_types()); foreach ($node_types as $node_type) { field_attach_delete_bundle('comment', 'comment_node_' . $node_type); - variable_del('comment_' . $node_type); - variable_del('comment_anonymous_' . $node_type); - variable_del('comment_controls_' . $node_type); - variable_del('comment_default_mode_' . $node_type); - variable_del('comment_default_order_' . $node_type); - variable_del('comment_default_per_page_' . $node_type); - variable_del('comment_form_location_' . $node_type); - variable_del('comment_preview_' . $node_type); - variable_del('comment_subject_field_' . $node_type); + config('comment.settings.' . $node_type)->clear('comment'); + config('comment.settings.' . $node_type)->clear('comment_anonymous'); + config('comment.settings.' . $node_type)->clear('comment_controls'); + config('comment.settings.' . $node_type)->clear('comment_default_mode'); + config('comment.settings.' . $node_type)->clear('comment_default_order'); + config('comment.settings.' . $node_type)->clear('comment_default_per_page'); + config('comment.settings.' . $node_type)->clear('comment_form_location'); + config('comment.settings.' . $node_type)->clear('comment_preview'); + config('comment.settings.' . $node_type)->clear('comment_subject_field'); } } @@ -288,6 +288,28 @@ function comment_update_8000() { ); db_change_field('comment', 'language', 'langcode', $langcode_spec); db_add_index('comment', 'comment_nid_langcode', array('nid', 'langcode')); + update_variables_to_config('comment.settings', array( + 'comment_block_count' => 'comment_block_count', + 'comment_maintain_node_statistics' => 'comment_maintain_node_statistics', + 'node_cron_comments_scale' => 'node_cron_comments_scale', + )); + $node_types = db_query('SELECT DISTINCT type FROM {node_type}')->fetchCol(); + $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) { + $node_types[$type] = $type; + } + foreach ($node_types as $type) { + update_variables_to_config("comment.settings.$type", array( + "comment_$type" => 'comment', + "comment_default_mode_$type" => 'comment_default_mode', + "comment_default_per_page_$type" => 'comment_default_per_page', + "comment_anonymous_$type" => 'comment_anonymous', + "comment_subject_field_$type" => 'comment_subject_field', + "comment_form_location_$type" => 'comment_form_location', + "comment_preview_$type" => 'comment_preview', + ), 'comment.settings.article'); + } } /** diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 1b1dd79..af69ce4 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -189,7 +189,7 @@ function comment_field_extra_fields() { $return = array(); foreach (node_type_get_types() as $type) { - if (variable_get('comment_subject_field_' . $type->type, 1) == 1) { + if (config('comment.settings.' . $type->type)->get('comment_subject_field') == 1) { $return['comment']['comment_node_' . $type->type] = array( 'form' => array( 'author' => array( @@ -363,6 +363,7 @@ function comment_node_type_update($info) { */ function comment_node_type_delete($info) { field_attach_delete_bundle('comment', 'comment_node_' . $info->type); + $config = config('comment.settings.' . $info->type); $settings = array( 'comment', 'comment_default_mode', @@ -373,8 +374,9 @@ function comment_node_type_delete($info) { 'comment_form_location', ); foreach ($settings as $setting) { - variable_del($setting . '_' . $info->type); + $config->clear($setting); } + $config->save(); } /** @@ -458,7 +460,7 @@ function comment_block_configure($delta = '') { $form['comment_block_count'] = array( '#type' => 'select', '#title' => t('Number of recent comments'), - '#default_value' => variable_get('comment_block_count', 10), + '#default_value' => config('comment.settings')->get('comment_block_count'), '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 25, 30)), ); @@ -469,7 +471,7 @@ function comment_block_configure($delta = '') { * Implements hook_block_save(). */ function comment_block_save($delta = '', $edit = array()) { - variable_set('comment_block_count', (int) $edit['comment_block_count']); + config('comment.settings')->set('comment_block_count', $edit['comment_block_count'])->save(); } /** @@ -564,8 +566,8 @@ function comment_get_recent($number = 10) { * "page=X" if the page number is greater than zero; empty string otherwise. */ function comment_new_page_count($num_comments, $new_replies, Node $node) { - $mode = variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED); - $comments_per_page = variable_get('comment_default_per_page_' . $node->type, 50); + $mode = config('comment.settings.' . $node->type)->get('comment_default_mode'); + $comments_per_page = config('comment.settings.' . $node->type)->get('comment_default_per_page'); $pagenum = NULL; $flat = $mode == COMMENT_MODE_FLAT ? TRUE : FALSE; if ($num_comments <= $comments_per_page) { @@ -625,7 +627,7 @@ function comment_new_page_count($num_comments, $new_replies, Node $node) { */ function theme_comment_block() { $items = array(); - $number = variable_get('comment_block_count', 10); + $number = config('comment.settings')->get('comment_block_count'); foreach (comment_get_recent($number) as $comment) { $items[] = l($comment->subject, 'comment/' . $comment->cid, array('fragment' => 'comment-' . $comment->cid)) . ' ' . t('@time ago', array('@time' => format_interval(REQUEST_TIME - $comment->changed))) . ''; } @@ -679,7 +681,7 @@ function comment_node_view(Node $node, $view_mode) { } } if ($node->comment == COMMENT_NODE_OPEN) { - $comment_form_location = variable_get('comment_form_location_' . $node->type, COMMENT_FORM_BELOW); + $comment_form_location = config('comment.settings.' . $node->type)->get('comment_form_location'); if (user_access('post comments')) { $links['comment-add'] = array( 'title' => t('Add new comment'), @@ -705,7 +707,7 @@ function comment_node_view(Node $node, $view_mode) { // But we don't want this link if we're building the node for search // indexing or constructing a search result excerpt. if ($node->comment == COMMENT_NODE_OPEN) { - $comment_form_location = variable_get('comment_form_location_' . $node->type, COMMENT_FORM_BELOW); + $comment_form_location = config('comment.settings.' . $node->type)->get('comment_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. @@ -758,13 +760,13 @@ function comment_node_view(Node $node, $view_mode) { */ function comment_node_page_additions(Node $node) { $additions = array(); - + $config = config('comment.settings.' . $node->type); // Only attempt to render comments if the node has visible comments. // Unpublished comments are not included in $node->comment_count, so show // comments unconditionally if the user is an administrator. if (($node->comment_count && user_access('access comments')) || user_access('administer comments')) { - $mode = variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED); - $comments_per_page = variable_get('comment_default_per_page_' . $node->type, 50); + $mode = $config->get('comment_default_mode'); + $comments_per_page = $config->get('comment_default_per_page'); if ($cids = comment_get_thread($node, $mode, $comments_per_page)) { $comments = comment_load_multiple($cids); comment_prepare_thread($comments); @@ -775,7 +777,7 @@ function comment_node_page_additions(Node $node) { } // Append comment form if needed. - if (user_access('post comments') && $node->comment == COMMENT_NODE_OPEN && (variable_get('comment_form_location_' . $node->type, COMMENT_FORM_BELOW) == COMMENT_FORM_BELOW)) { + if (user_access('post comments') && $node->comment == COMMENT_NODE_OPEN && ($config->get('comment_form_location') == COMMENT_FORM_BELOW)) { $additions['comment_form'] = comment_add($node); } @@ -874,6 +876,7 @@ function comment_add(Node $node, $pid = NULL) { * to consider the trailing "/" so we use a substring only. */ function comment_get_thread(Node $node, $mode, $comments_per_page) { + $query = db_select('comment', 'c') ->extend('Drupal\Core\Database\Query\PagerSelectExtender'); $query->addField('c', 'cid'); @@ -898,7 +901,7 @@ function comment_get_thread(Node $node, $mode, $comments_per_page) { $query->condition('c.status', COMMENT_PUBLISHED); $count_query->condition('c.status', COMMENT_PUBLISHED); } - if ($mode === COMMENT_MODE_FLAT) { + if ((int)$mode === COMMENT_MODE_FLAT) { $query->orderBy('c.cid', 'ASC'); } else { @@ -998,7 +1001,7 @@ function comment_view(Comment $comment, Node $node, $view_mode = 'full', $langco if (empty($comment->in_preview)) { $prefix = ''; - $is_threaded = isset($comment->divs) && variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED) == COMMENT_MODE_THREADED; + $is_threaded = isset($comment->divs) && (config('comment.settings.' . $node->type)->get('comment_default_mode') == COMMENT_MODE_THREADED); // Add 'new' anchor if needed. if (!empty($comment->first_new)) { @@ -1177,6 +1180,7 @@ function comment_view_multiple($comments, Node $node, $view_mode = 'full', $weig * Implements hook_form_FORM_ID_alter(). */ function comment_form_node_type_form_alter(&$form, $form_state) { + $config = config('comment.settings.' . $form['#node_type']->type); if (isset($form['type'])) { $form['comment'] = array( '#type' => 'fieldset', @@ -1194,32 +1198,36 @@ function comment_form_node_type_form_alter(&$form, $form_state) { // Unlike coment_form_node_form_alter(), all of these settings are applied // as defaults to all new nodes. Therefore, it would be wrong to use #states // to hide the other settings based on the primary comment setting. + $comment = $config->get('comment'); $form['comment']['comment'] = array( '#type' => 'select', '#title' => t('Default comment setting for new content'), - '#default_value' => variable_get('comment_' . $form['#node_type']->type, COMMENT_NODE_OPEN), + '#default_value' => isset($comment) ? $comment : COMMENT_NODE_OPEN, '#options' => array( COMMENT_NODE_OPEN => t('Open'), COMMENT_NODE_CLOSED => t('Closed'), COMMENT_NODE_HIDDEN => t('Hidden'), ), ); + $comment_default_mode = $config->get('comment_default_mode'); $form['comment']['comment_default_mode'] = array( '#type' => 'checkbox', '#title' => t('Threading'), - '#default_value' => variable_get('comment_default_mode_' . $form['#node_type']->type, COMMENT_MODE_THREADED), + '#default_value' => isset($comment_default_mode) ? $comment_default_mode : 1, '#description' => t('Show comment replies in a threaded list.'), ); + $comment_default_per_page = $config->get('comment_default_per_page'); $form['comment']['comment_default_per_page'] = array( '#type' => 'select', '#title' => t('Comments per page'), - '#default_value' => variable_get('comment_default_per_page_' . $form['#node_type']->type, 50), + '#default_value' => isset($comment_default_per_page) ? $comment_default_per_page : '50', '#options' => _comment_per_page(), ); + $comment_anonymous = $config->get('comment_anonymous'); $form['comment']['comment_anonymous'] = array( '#type' => 'select', '#title' => t('Anonymous commenting'), - '#default_value' => variable_get('comment_anonymous_' . $form['#node_type']->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT), + '#default_value' => isset($comment_anonymous) ? $comment_anonymous : 0, '#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'), @@ -1227,30 +1235,51 @@ function comment_form_node_type_form_alter(&$form, $form_state) { ), '#access' => user_access('post comments', drupal_anonymous_user()), ); + $comment_subject_field = $config->get('comment_subject_field'); $form['comment']['comment_subject_field'] = array( '#type' => 'checkbox', '#title' => t('Allow comment title'), - '#default_value' => variable_get('comment_subject_field_' . $form['#node_type']->type, 1), + '#default_value' => isset($comment_subject_field) ? $comment_subject_field : 1, ); + $comment_form_location = $config->get('comment_form_location'); $form['comment']['comment_form_location'] = array( '#type' => 'checkbox', '#title' => t('Show reply form on the same page as comments'), - '#default_value' => variable_get('comment_form_location_' . $form['#node_type']->type, COMMENT_FORM_BELOW), + '#default_value' => isset($comment_form_location) ? $comment_form_location : 1, ); + $comment_preview = $config->get('comment_preview'); $form['comment']['comment_preview'] = array( '#type' => 'radios', '#title' => t('Preview comment'), - '#default_value' => variable_get('comment_preview_' . $form['#node_type']->type, DRUPAL_OPTIONAL), + '#default_value' => isset($comment_preview) ? $comment_preview : DRUPAL_OPTIONAL, '#options' => array( DRUPAL_DISABLED => t('Disabled'), DRUPAL_OPTIONAL => t('Optional'), DRUPAL_REQUIRED => t('Required'), ), ); + $form['#submit'][] = 'comment_submit_config'; } } /** + * Implements callback submit to store conf values + * for the node type form(). + */ +function comment_submit_config($form, &$form_state) { + config('comment.settings.' . $form['#node_type']->type) + ->set('comment', $form_state['values']['comment']) + ->set('comment_default_mode', $form_state['values']['comment_default_mode']) + ->set('comment_default_per_page', $form_state['values']['comment_default_per_page']) + ->set('comment_anonymous', $form_state['values']['comment_anonymous']) + ->set('comment_subject_field', $form_state['values']['comment_subject_field']) + ->set('comment_form_location', $form_state['values']['comment_form_location']) + ->set('comment_preview', $form_state['values']['comment_preview']) + ->save(); + watchdog('comment', 'CMI configuration variables updated for node type %type', array('%type' => $form['#node_type']->type)); +} + +/** * Implements hook_form_BASE_FORM_ID_alter(). */ function comment_form_node_form_alter(&$form, $form_state) { @@ -1300,6 +1329,7 @@ function comment_form_node_form_alter(&$form, $form_state) { // Also adjust the description of the "closed" option. $form['comment_settings']['comment'][COMMENT_NODE_CLOSED]['#description'] = t('Users cannot post comments.'); } + $form['#submit'][] = 'comment_node_submit_config'; } /** @@ -1342,7 +1372,7 @@ function comment_node_load($nodes, $types) { */ function comment_node_prepare(Node $node) { if (!isset($node->comment)) { - $node->comment = variable_get("comment_$node->type", COMMENT_NODE_OPEN); + $node->comment = config('comment.settings.' . $node->type)->get('comment'); } } @@ -1350,9 +1380,10 @@ function comment_node_prepare(Node $node) { * Implements hook_node_insert(). */ function comment_node_insert(Node $node) { + $config = config('comment.settings'); // Allow bulk updates and inserts to temporarily disable the // maintenance of the {node_comment_statistics} table. - if (variable_get('comment_maintain_node_statistics', TRUE)) { + if ($config->get('comment_maintain_node_statistics')) { db_insert('node_comment_statistics') ->fields(array( 'nid' => $node->nid, @@ -1403,8 +1434,8 @@ function comment_node_update_index(Node $node, $langcode) { } if ($index_comments) { - $mode = variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED); - $comments_per_page = variable_get('comment_default_per_page_' . $node->type, 50); + $mode = config('comment.settings.' . $node->type)->get('comment_default_mode'); + $comments_per_page = config('comment.settings.' . $node->type)->get('comment_default_per_page'); if ($node->comment && $cids = comment_get_thread($node, $mode, $comments_per_page)) { $comments = comment_load_multiple($cids); comment_prepare_thread($comments); @@ -1420,7 +1451,7 @@ function comment_node_update_index(Node $node, $langcode) { */ function comment_update_index() { // Store the maximum possible comments per thread (used for ranking by reply count) - variable_set('node_cron_comments_scale', 1.0 / max(1, db_query('SELECT MAX(comment_count) FROM {node_comment_statistics}')->fetchField())); + config('comment.settings')->set('node_cron_comments_scale', 1.0 / max(1, db_query('SELECT MAX(comment_count) FROM {node_comment_statistics}')->fetchField()))->save(); } /** @@ -1616,6 +1647,7 @@ function comment_num_new($nid, $timestamp = 0) { * @see comment_get_display_page() */ function comment_get_display_ordinal($cid, $node_type) { + $config = config('comment.settings.' . $node_type); // Count how many comments (c1) are before $cid (c2) in display order. This is // the 0-based display ordinal. $query = db_select('comment', 'c1'); @@ -1625,7 +1657,7 @@ function comment_get_display_ordinal($cid, $node_type) { if (!user_access('administer comments')) { $query->condition('c1.status', COMMENT_PUBLISHED); } - $mode = variable_get('comment_default_mode_' . $node_type, COMMENT_MODE_THREADED); + $mode = $config->get('comment_default_mode'); if ($mode == COMMENT_MODE_FLAT) { // For flat comments, cid is used for ordering comments due to @@ -1658,8 +1690,9 @@ function comment_get_display_ordinal($cid, $node_type) { * The page number. */ function comment_get_display_page($cid, $node_type) { + $config = config('comment.settings.' . $node_type); $ordinal = comment_get_display_ordinal($cid, $node_type); - $comments_per_page = variable_get('comment_default_per_page_' . $node_type, 50); + $comments_per_page = $config->get('comment_default_per_page'); return floor($ordinal / $comments_per_page); } @@ -1816,7 +1849,7 @@ function template_preprocess_comment(&$variables) { function theme_comment_post_forbidden($variables) { $node = $variables['node']; global $user; - + $config = config('comment.settings.' . $node->type); // Since this is expensive to compute, we cache it so that a page with many // comments only has to query the database once for all the links. $authenticated_post_comments = &drupal_static(__FUNCTION__, NULL); @@ -1832,7 +1865,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 (variable_get('comment_form_location_' . $node->type, COMMENT_FORM_BELOW) == COMMENT_FORM_SEPARATE_PAGE) { + if ($config->get('comment_form_location') == COMMENT_FORM_SEPARATE_PAGE) { $destination = array('destination' => "comment/reply/$node->nid#comment-form"); } else { @@ -1860,7 +1893,7 @@ function theme_comment_post_forbidden($variables) { function template_preprocess_comment_wrapper(&$variables) { // Provide contextual information. $variables['node'] = $variables['content']['#node']; - $variables['display_mode'] = variable_get('comment_default_mode_' . $variables['node']->type, COMMENT_MODE_THREADED); + $variables['display_mode'] = config('comment.settings.' . $variables['node']->type)->get('comment_default_mode'); // The comment form is optional and may not exist. $variables['content'] += array('comment_form' => array()); } @@ -2083,7 +2116,7 @@ function comment_ranking() { ), // Inverse law that maps the highest reply count on the site to 1 and 0 to 0. 'score' => '2.0 - 2.0 / (1.0 + node_comment_statistics.comment_count * CAST(:scale AS DECIMAL))', - 'arguments' => array(':scale' => variable_get('node_cron_comments_scale', 0)), + 'arguments' => array(':scale' => config('comment.settings')->get('node_cron_comments_scale')), ), ); } diff --git a/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php index f0f16c2..7c03797 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentFormController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php @@ -20,6 +20,7 @@ class CommentFormController extends EntityFormController { */ public function form(array $form, array &$form_state, EntityInterface $comment) { global $user; + $language_content = language(LANGUAGE_TYPE_CONTENT); $node = node_load($comment->nid); @@ -28,8 +29,7 @@ class CommentFormController extends EntityFormController { // Use #comment-form as unique jump target, regardless of node type. $form['#id'] = drupal_html_id('comment_form'); $form['#theme'] = array('comment_form__node_' . $node->type, 'comment_form'); - - $anonymous_contact = variable_get('comment_anonymous_' . $node->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT); + $anonymous_contact = config('comment.settings.' . $node->type)->get('comment_anonymous'); $is_admin = (!empty($comment->cid) && user_access('administer comments')); if (!$user->uid && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT) { @@ -159,7 +159,7 @@ class CommentFormController extends EntityFormController { '#title' => t('Subject'), '#maxlength' => 64, '#default_value' => $comment->subject, - '#access' => variable_get('comment_subject_field_' . $node->type, 1) == 1, + '#access' => config('comment.settings.' . $node->type)->get('comment_subject_field') == 1, ); // Used for conditional validation of author fields. @@ -199,7 +199,7 @@ class CommentFormController extends EntityFormController { $element = parent::actions($form, $form_state); $comment = $this->getEntity($form_state); $node = $form_state['comment']['node']; - $preview_mode = variable_get('comment_preview_' . $node->type, DRUPAL_OPTIONAL); + $preview_mode = config('comment.settings.' . $node->type)->get('comment_preview'); // No delete action on the comment form. unset($element['delete']); diff --git a/core/modules/comment/lib/Drupal/comment/CommentStorageController.php b/core/modules/comment/lib/Drupal/comment/CommentStorageController.php index 5dcda40..9c8e54f 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentStorageController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentStorageController.php @@ -195,7 +195,7 @@ class CommentStorageController extends DatabaseStorageController { protected function updateNodeStatistics($nid) { // Allow bulk updates and inserts to temporarily disable the // maintenance of the {node_comment_statistics} table. - if (!variable_get('comment_maintain_node_statistics', TRUE)) { + if (!config('comment.settings')->get('comment_maintain_node_statistics')) { return; } diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php index e122141..7b5e94d 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php @@ -548,8 +548,10 @@ class CommentInterfaceTest extends CommentTestBase { } // Change comment settings. - variable_set('comment_form_location_' . $this->node->type, $info['form']); - variable_set('comment_anonymous_' . $this->node->type, $info['contact']); + config('comment.settings.' . $this->node->type) + ->set('comment_form_location', $info['form']) + ->set('comment_anonymous', $info['contact']) + ->save(); if ($this->node->comment != $info['comments']) { $this->node->comment = $info['comments']; node_save($this->node); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php index 24d5b39..2669121 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php @@ -51,16 +51,15 @@ abstract class CommentTestBase extends WebTestBase { $langcode = LANGUAGE_NOT_SPECIFIED; $edit = array(); $edit['comment_body[' . $langcode . '][0][value]'] = $comment; - - $preview_mode = variable_get('comment_preview_article', DRUPAL_OPTIONAL); - $subject_mode = variable_get('comment_subject_field_article', 1); + $preview_mode = config('comment.settings.article')->get('comment_preview'); + $subject_mode = config('comment.settings.article')->get('comment_subject_field'); // Must get the page before we test for fields. if ($node !== NULL) { $this->drupalGet('comment/reply/' . $node->nid); } - if ($subject_mode == TRUE) { + if ($subject_mode) { $edit['subject'] = $subject; } else { @@ -223,7 +222,7 @@ abstract class CommentTestBase extends WebTestBase { * Status message to display. */ function setCommentSettings($name, $value, $message) { - variable_set($name . '_article', $value); + config('comment.settings.article')->set($name, $value)->save(); $this->assertTrue(TRUE, t($message)); // Display status message. }