diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install index 0a147b5..14e154f 100644 --- a/core/modules/comment/comment.install +++ b/core/modules/comment/comment.install @@ -288,6 +288,56 @@ 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', + )); + update_variables_to_config('comment.settings.article', array( + 'comment_article' => 'comment', + 'comment_default_mode_article' => 'comment_default_mode', + 'comment_default_per_page_article' => 'comment_default_per_page', + 'comment_anonymous_article' => 'comment_anonymous', + 'comment_subject_field_article' => 'comment_subject_field', + 'comment_form_location_article' => 'comment_form_location', + 'comment_preview_article' => 'comment_preview', + )); + update_variables_to_config('comment.settings.page', array( + 'comment_page' => 'comment', + 'comment_default_mode_page' => 'comment_default_mode', + 'comment_default_per_page_page' => 'comment_default_per_page', + 'comment_anonymous_page' => 'comment_anonymous', + 'comment_subject_field_page' => 'comment_subject_field', + 'comment_form_location_page' => 'comment_form_location', + 'comment_preview_page' => 'comment_preview', + )); + update_variables_to_config('comment.settings.book', array( + 'comment_book' => 'comment', + 'comment_default_mode_book' => 'comment_default_mode', + 'comment_default_per_page_book' => 'comment_default_per_page', + 'comment_anonymous_book' => 'comment_anonymous', + 'comment_subject_field_book' => 'comment_subject_field', + 'comment_form_location_book' => 'comment_form_location', + 'comment_preview_book' => 'comment_preview', + )); + update_variables_to_config('comment.settings.poll', array( + 'comment_poll' => 'comment', + 'comment_default_mode_poll' => 'comment_default_mode', + 'comment_default_per_page_poll' => 'comment_default_per_page', + 'comment_anonymous_poll' => 'comment_anonymous', + 'comment_subject_field_poll' => 'comment_subject_field', + 'comment_form_location_poll' => 'comment_form_location', + 'comment_preview_poll' => 'comment_preview', + )); + update_variables_to_config('comment.settings.forum', array( + 'comment_forum' => 'comment', + 'comment_default_mode_forum' => 'comment_default_mode', + 'comment_default_per_page_forum' => 'comment_default_per_page', + 'comment_anonymous_forum' => 'comment_anonymous', + 'comment_subject_field_forum' => 'comment_subject_field', + 'comment_form_location_forum' => 'comment_form_location', + 'comment_preview_forum' => 'comment_preview', + )); } /** diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 1b1dd79..1d5a582 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -189,7 +189,8 @@ function comment_field_extra_fields() { $return = array(); foreach (node_type_get_types() as $type) { - if (variable_get('comment_subject_field_' . $type->type, 1) == 1) { + $config = config('comment.settings.' . $type->type); + if (intval($config->get('comment_subject_field')) == 1) { $return['comment']['comment_node_' . $type->type] = array( 'form' => array( 'author' => array( @@ -363,6 +364,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 +375,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 +461,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' => intval(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 +472,9 @@ 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 = config('comment.settings'); + $config->set('comment_block_count', $edit['comment_block_count']); + $config->save(); } /** @@ -564,8 +569,9 @@ 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); + $config = config('comment.settings.' . $node->type); + $mode = intval($config->get('comment_default_mode')); + $comments_per_page = intval($config->get('comment_default_per_page')); $pagenum = NULL; $flat = $mode == COMMENT_MODE_FLAT ? TRUE : FALSE; if ($num_comments <= $comments_per_page) { @@ -625,7 +631,8 @@ function comment_new_page_count($num_comments, $new_replies, Node $node) { */ function theme_comment_block() { $items = array(); - $number = variable_get('comment_block_count', 10); + $config = config('comment.settings'); + $number = intval($config->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 +686,8 @@ 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); + $config = config('comment.settings.' . $node->type); + $comment_form_location = intval($config->get('comment_form_location')); if (user_access('post comments')) { $links['comment-add'] = array( 'title' => t('Add new comment'), @@ -705,7 +713,8 @@ 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); + $config = config('comment.settings.' . $node->type); + $comment_form_location = intval($config->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 +767,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 = intval($config->get('comment_default_mode')); + $comments_per_page = intval($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 +784,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 && (intval($config->get('comment_form_location')) == COMMENT_FORM_BELOW)) { $additions['comment_form'] = comment_add($node); } @@ -874,6 +883,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'); @@ -977,6 +987,7 @@ function comment_prepare_thread(&$comments) { * An array as expected by drupal_render(). */ function comment_view(Comment $comment, Node $node, $view_mode = 'full', $langcode = NULL) { + $config = config('comment.settings.' . $node->type); if (!isset($langcode)) { $langcode = language(LANGUAGE_TYPE_CONTENT)->langcode; } @@ -998,7 +1009,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) && (intval($config->get('comment_default_mode')) == COMMENT_MODE_THREADED); // Add 'new' anchor if needed. if (!empty($comment->first_new)) { @@ -1177,6 +1188,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 +1206,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 = intval($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 = intval($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 = intval($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 = intval($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 +1243,51 @@ function comment_form_node_type_form_alter(&$form, $form_state) { ), '#access' => user_access('post comments', drupal_anonymous_user()), ); + $comment_subject_field = intval($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 = intval($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 = intval($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_DISABLED, '#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 = config('comment.settings.' . $form['#node_type']->type); + $config->set('comment', $form_state['values']['comment']); + $config->set('comment_default_mode', $form_state['values']['comment_default_mode']); + $config->set('comment_default_per_page', $form_state['values']['comment_default_per_page']); + $config->set('comment_anonymous', $form_state['values']['comment_anonymous']); + $config->set('comment_subject_field', $form_state['values']['comment_subject_field']); + $config->set('comment_form_location', $form_state['values']['comment_form_location']); + $config->set('comment_preview', $form_state['values']['comment_preview']); + $config->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 +1337,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 +1380,8 @@ 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); + $config = config('comment.settings.' . $node->type); + $node->comment = intval($config->get('comment')); } } @@ -1350,9 +1389,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, @@ -1381,6 +1421,7 @@ function comment_node_predelete(Node $node) { * Implements hook_node_update_index(). */ function comment_node_update_index(Node $node, $langcode) { + $config = config('comment.settings.' . $node->type); $index_comments = &drupal_static(__FUNCTION__); if ($index_comments === NULL) { @@ -1403,8 +1444,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 = intval($config->get('comment_default_mode')); + $comments_per_page = intval($config->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); @@ -1419,8 +1460,10 @@ function comment_node_update_index(Node $node, $langcode) { * Implements hook_update_index(). */ function comment_update_index() { + $config = config('comment.settings'); // 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->set('node_cron_comments_scale', 1.0 / max(1, db_query('SELECT MAX(comment_count) FROM {node_comment_statistics}')->fetchField())); + $config->save(); } /** @@ -1616,6 +1659,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 +1669,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 = intval($config->get('comment_default_mode')); if ($mode == COMMENT_MODE_FLAT) { // For flat comments, cid is used for ordering comments due to @@ -1658,8 +1702,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 = intval($config->get('comment_default_per_page')); return floor($ordinal / $comments_per_page); } @@ -1816,7 +1861,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 +1877,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 (intval($config->get('comment_form_location')) == COMMENT_FORM_SEPARATE_PAGE) { $destination = array('destination' => "comment/reply/$node->nid#comment-form"); } else { @@ -1860,7 +1905,8 @@ 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); + $config = config('comment.settings.' . $variables['node']->type); + $variables['display_mode'] = intval($config->get('comment_default_mode')); // The comment form is optional and may not exist. $variables['content'] += array('comment_form' => array()); } @@ -2072,6 +2118,7 @@ function comment_save_action(Comment $comment) { * Implements hook_ranking(). */ function comment_ranking() { + $config = config('comment.settings'); return array( 'comments' => array( 'title' => t('Number of comments'), @@ -2083,7 +2130,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' => intval($config->get('node_cron_comments_scale'))), ), ); } diff --git a/core/modules/comment/config/comment.settings.article.yml b/core/modules/comment/config/comment.settings.article.yml new file mode 100755 index 0000000..e26b635 --- /dev/null +++ b/core/modules/comment/config/comment.settings.article.yml @@ -0,0 +1,7 @@ +comment: '2' +comment_default_mode: '1' +comment_default_per_page: '50' +comment_anonymous: '0' +comment_subject_field: '1' +comment_form_location: '1' +comment_preview: '0' diff --git a/core/modules/comment/config/comment.settings.book.yml b/core/modules/comment/config/comment.settings.book.yml new file mode 100755 index 0000000..e26b635 --- /dev/null +++ b/core/modules/comment/config/comment.settings.book.yml @@ -0,0 +1,7 @@ +comment: '2' +comment_default_mode: '1' +comment_default_per_page: '50' +comment_anonymous: '0' +comment_subject_field: '1' +comment_form_location: '1' +comment_preview: '0' diff --git a/core/modules/comment/config/comment.settings.forum.yml b/core/modules/comment/config/comment.settings.forum.yml new file mode 100755 index 0000000..e26b635 --- /dev/null +++ b/core/modules/comment/config/comment.settings.forum.yml @@ -0,0 +1,7 @@ +comment: '2' +comment_default_mode: '1' +comment_default_per_page: '50' +comment_anonymous: '0' +comment_subject_field: '1' +comment_form_location: '1' +comment_preview: '0' diff --git a/core/modules/comment/config/comment.settings.page.yml b/core/modules/comment/config/comment.settings.page.yml new file mode 100755 index 0000000..e26b635 --- /dev/null +++ b/core/modules/comment/config/comment.settings.page.yml @@ -0,0 +1,7 @@ +comment: '2' +comment_default_mode: '1' +comment_default_per_page: '50' +comment_anonymous: '0' +comment_subject_field: '1' +comment_form_location: '1' +comment_preview: '0' diff --git a/core/modules/comment/config/comment.settings.poll.yml b/core/modules/comment/config/comment.settings.poll.yml new file mode 100755 index 0000000..e26b635 --- /dev/null +++ b/core/modules/comment/config/comment.settings.poll.yml @@ -0,0 +1,7 @@ +comment: '2' +comment_default_mode: '1' +comment_default_per_page: '50' +comment_anonymous: '0' +comment_subject_field: '1' +comment_form_location: '1' +comment_preview: '0' diff --git a/core/modules/comment/config/comment.settings.yml b/core/modules/comment/config/comment.settings.yml new file mode 100755 index 0000000..fee7c27 --- /dev/null +++ b/core/modules/comment/config/comment.settings.yml @@ -0,0 +1,3 @@ +comment_block_count: '10' +comment_maintain_node_statistics: '1' +node_cron_comments_scale: '0' diff --git a/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php index f0f16c2..63c2b7d 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentFormController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php @@ -20,16 +20,17 @@ 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); + $config = config('comment.settings.' . $node->type); $form_state['comment']['node'] = $node; // 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 = intval($config->get('comment_anonymous')); $is_admin = (!empty($comment->cid) && user_access('administer comments')); if (!$user->uid && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT) { @@ -159,7 +160,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' => intval($config->get('comment_subject_field')) == 1, ); // Used for conditional validation of author fields. @@ -199,7 +200,8 @@ 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); + $config = config('comment.settings.' . $node->type) ; + $preview_mode = intval($config->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..5e616b8 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentStorageController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentStorageController.php @@ -195,7 +195,8 @@ 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)) { + $config = config('comment.settings'); + if (!$config->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..a93cf88 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 = config('comment.settings.' . $this->node->type); + $config->set('comment_form_location', $info['form']); + $config->set('comment_anonymous', $info['contact']); + $config->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..de3fa77 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php @@ -51,16 +51,16 @@ 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); + $config = config('comment.settings.article'); + $preview_mode = intval($config->get('comment_preview')); + $subject_mode = intval($config->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 == 1) { $edit['subject'] = $subject; } else { @@ -223,7 +223,9 @@ abstract class CommentTestBase extends WebTestBase { * Status message to display. */ function setCommentSettings($name, $value, $message) { - variable_set($name . '_article', $value); + $config = config('comment.settings.article'); + $config->set($name, $value); + $config->save(); $this->assertTrue(TRUE, t($message)); // Display status message. }