diff --git a/core/includes/update.inc b/core/includes/update.inc
index 9dd8456..926dfe3 100644
--- a/core/includes/update.inc
+++ b/core/includes/update.inc
@@ -1044,8 +1044,11 @@ function update_variable_del($name) {
* @endcode
* 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.
+ * @param string $default_config_name
+ * The name of the configuration object to copy data from if $config_name
+ * does not yet exist.
*/
-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.
@@ -1057,10 +1060,15 @@ function update_variables_to_config($config_name, array $variable_map) {
// Load and set default configuration values.
$file = new FileStorage(drupal_get_path('module', $module) . '/config');
- if (!$file->exists($config_name)) {
+ 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.
diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install
index 0a147b5..5b614ad 100644
--- a/core/modules/comment/comment.install
+++ b/core/modules/comment/comment.install
@@ -13,19 +13,11 @@ function comment_uninstall() {
field_delete_field('comment_body');
// Remove variables.
- variable_del('comment_block_count');
+ config('comment.settings')->delete();
$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)->delete();
}
}
@@ -317,6 +309,34 @@ function comment_update_8001() {
}
/**
+ * Update comment settings to the new configuration settings.
+ */
+function comment_update_8002() {
+ update_variables_to_config('comment.settings', array(
+ 'comment_block_count' => 'block.count.display',
+ 'comment_maintain_node_statistics' => '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" => 'status',
+ "comment_default_mode_$type" => 'default_mode',
+ "comment_default_per_page_$type" => 'default_per_page',
+ "comment_anonymous_$type" => 'anonymous',
+ "comment_subject_field_$type" => 'subject_field',
+ "comment_form_location_$type" => 'form_location',
+ "comment_preview_$type" => 'preview',
+ ), 'comment.settings.article');
+ }
+}
+
+/**
* @} End of "addtogroup updates-7.x-to-8.x".
* The next series of updates should start at 9000.
*/
diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index 1b1dd79..28af854 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('subject_field')) {
$return['comment']['comment_node_' . $type->type] = array(
'form' => array(
'author' => array(
@@ -363,18 +363,20 @@ 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',
- 'comment_default_per_page',
- 'comment_anonymous',
- 'comment_subject_field',
- 'comment_preview',
- 'comment_form_location',
+ 'status',
+ 'default_mode',
+ 'default_per_page',
+ 'anonymous',
+ 'subject_field',
+ 'preview',
+ '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('block.count.display'),
'#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,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('comment.settings')
+ ->set('block.count.display', $edit['comment_block_count'])
+ ->save();
}
/**
@@ -564,8 +568,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 = $config->get('default_mode');
+ $comments_per_page = $config->get('default_per_page');
$pagenum = NULL;
$flat = $mode == COMMENT_MODE_FLAT ? TRUE : FALSE;
if ($num_comments <= $comments_per_page) {
@@ -625,7 +630,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('block.count.display');
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 +684,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('form_location');
if (user_access('post comments')) {
$links['comment-add'] = array(
'title' => t('Add new comment'),
@@ -705,7 +710,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('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 +763,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('default_mode');
+ $comments_per_page = $config->get('default_per_page');
if ($cids = comment_get_thread($node, $mode, $comments_per_page)) {
$comments = comment_load_multiple($cids);
comment_prepare_thread($comments);
@@ -775,7 +780,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('form_location') == COMMENT_FORM_BELOW)) {
$additions['comment_form'] = comment_add($node);
}
@@ -874,6 +879,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 +904,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 +1004,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('default_mode') == COMMENT_MODE_THREADED);
// Add 'new' anchor if needed.
if (!empty($comment->first_new)) {
@@ -1177,6 +1183,8 @@ 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 +1202,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('status');
$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('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('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('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 +1239,50 @@ function comment_form_node_type_form_alter(&$form, $form_state) {
),
'#access' => user_access('post comments', drupal_anonymous_user()),
);
+ $comment_subject_field = $config->get('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('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('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('status', $form_state['values']['comment'])
+ ->set('default_mode', $form_state['values']['comment_default_mode'])
+ ->set('default_per_page', $form_state['values']['comment_default_per_page'])
+ ->set('anonymous', $form_state['values']['comment_anonymous'])
+ ->set('subject_field', $form_state['values']['comment_subject_field'])
+ ->set('form_location', $form_state['values']['comment_form_location'])
+ ->set('preview', $form_state['values']['comment_preview'])
+ ->save();
+}
+
+/**
* Implements hook_form_BASE_FORM_ID_alter().
*/
function comment_form_node_form_alter(&$form, $form_state) {
@@ -1300,6 +1332,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 +1375,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('status');
}
}
@@ -1352,7 +1385,7 @@ function comment_node_prepare(Node $node) {
function comment_node_insert(Node $node) {
// 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('maintain_node_statistics')) {
db_insert('node_comment_statistics')
->fields(array(
'nid' => $node->nid,
@@ -1403,8 +1436,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('default_mode');
+ $comments_per_page = config('comment.settings.' . $node->type)->get('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 +1453,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 +1649,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 +1659,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('default_mode');
if ($mode == COMMENT_MODE_FLAT) {
// For flat comments, cid is used for ordering comments due to
@@ -1658,8 +1692,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('default_per_page');
return floor($ordinal / $comments_per_page);
}
@@ -1816,7 +1851,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 +1867,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('form_location') == COMMENT_FORM_SEPARATE_PAGE) {
$destination = array('destination' => "comment/reply/$node->nid#comment-form");
}
else {
@@ -1860,7 +1895,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('default_mode');
// The comment form is optional and may not exist.
$variables['content'] += array('comment_form' => array());
}
@@ -2083,7 +2118,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/config/comment.settings.article.yml b/core/modules/comment/config/comment.settings.article.yml
index e69de29..4578fd1 100755
--- a/core/modules/comment/config/comment.settings.article.yml
+++ b/core/modules/comment/config/comment.settings.article.yml
@@ -0,0 +1,7 @@
+status: '2'
+default_mode: '1'
+default_per_page: '50'
+anonymous: '0'
+subject_field: '1'
+form_location: '1'
+preview: '1'
diff --git a/core/modules/comment/config/comment.settings.blog.yml b/core/modules/comment/config/comment.settings.blog.yml
index e69de29..4578fd1 100755
--- a/core/modules/comment/config/comment.settings.blog.yml
+++ b/core/modules/comment/config/comment.settings.blog.yml
@@ -0,0 +1,7 @@
+status: '2'
+default_mode: '1'
+default_per_page: '50'
+anonymous: '0'
+subject_field: '1'
+form_location: '1'
+preview: '1'
diff --git a/core/modules/comment/config/comment.settings.book.yml b/core/modules/comment/config/comment.settings.book.yml
index e69de29..4578fd1 100755
--- a/core/modules/comment/config/comment.settings.book.yml
+++ b/core/modules/comment/config/comment.settings.book.yml
@@ -0,0 +1,7 @@
+status: '2'
+default_mode: '1'
+default_per_page: '50'
+anonymous: '0'
+subject_field: '1'
+form_location: '1'
+preview: '1'
diff --git a/core/modules/comment/config/comment.settings.forum.yml b/core/modules/comment/config/comment.settings.forum.yml
index e69de29..4578fd1 100755
--- a/core/modules/comment/config/comment.settings.forum.yml
+++ b/core/modules/comment/config/comment.settings.forum.yml
@@ -0,0 +1,7 @@
+status: '2'
+default_mode: '1'
+default_per_page: '50'
+anonymous: '0'
+subject_field: '1'
+form_location: '1'
+preview: '1'
diff --git a/core/modules/comment/config/comment.settings.page.yml b/core/modules/comment/config/comment.settings.page.yml
index e69de29..4578fd1 100755
--- a/core/modules/comment/config/comment.settings.page.yml
+++ b/core/modules/comment/config/comment.settings.page.yml
@@ -0,0 +1,7 @@
+status: '2'
+default_mode: '1'
+default_per_page: '50'
+anonymous: '0'
+subject_field: '1'
+form_location: '1'
+preview: '1'
diff --git a/core/modules/comment/config/comment.settings.poll.yml b/core/modules/comment/config/comment.settings.poll.yml
index e69de29..4578fd1 100755
--- a/core/modules/comment/config/comment.settings.poll.yml
+++ b/core/modules/comment/config/comment.settings.poll.yml
@@ -0,0 +1,7 @@
+status: '2'
+default_mode: '1'
+default_per_page: '50'
+anonymous: '0'
+subject_field: '1'
+form_location: '1'
+preview: '1'
diff --git a/core/modules/comment/config/comment.settings.yml b/core/modules/comment/config/comment.settings.yml
index e69de29..567bf4c 100755
--- a/core/modules/comment/config/comment.settings.yml
+++ b/core/modules/comment/config/comment.settings.yml
@@ -0,0 +1,5 @@
+block:
+ count:
+ display: '10'
+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..50139c3 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('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('subject_field'),
);
// 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('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..02a3ca2 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('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..b38a841 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentInterfaceTest.php
@@ -26,7 +26,7 @@ class CommentInterfaceTest extends CommentTestBase {
$this->setCommentPreview(DRUPAL_DISABLED);
$this->setCommentForm(TRUE);
$this->setCommentSubject(FALSE);
- $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
+ $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
$this->drupalLogout();
// Post comment #1 without subject or preview.
@@ -342,7 +342,7 @@ class CommentInterfaceTest extends CommentTestBase {
$this->setCommentPreview(DRUPAL_DISABLED);
$this->setCommentForm(TRUE);
$this->setCommentSubject(FALSE);
- $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
+ $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
$this->drupalLogout();
// Creates a second user to post comments.
@@ -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('form_location', $info['form'])
+ ->set('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/CommentNodeAccessTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentNodeAccessTest.php
index 74d9739..b4889c0 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentNodeAccessTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentNodeAccessTest.php
@@ -52,7 +52,7 @@ class CommentNodeAccessTest extends CommentTestBase {
$this->setCommentPreview(DRUPAL_DISABLED);
$this->setCommentForm(TRUE);
$this->setCommentSubject(TRUE);
- $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
+ $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, t('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 df7c8f1..ab54fe1 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 @@ class CommentPagerTest extends CommentTestBase {
$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, t('Comment paging changed.'));
+ $this->setCommentSettings('default_mode', COMMENT_MODE_FLAT, t('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.
@@ -78,7 +78,7 @@ class CommentPagerTest extends CommentTestBase {
// 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, t('Switched to threaded mode.'));
+ $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, t('Switched to threaded mode.'));
$this->drupalGet('node/' . $node->nid, array('query' => array('page' => 0)));
$this->assertTrue($this->commentExists($reply, TRUE), t('In threaded mode, reply appears on page 1.'));
$this->assertFalse($this->commentExists($comments[1]), t('In threaded mode, comment 2 has been bumped off of page 1.'));
@@ -138,7 +138,7 @@ class CommentPagerTest extends CommentTestBase {
// - 2
// - 5
- $this->setCommentSettings('comment_default_mode', COMMENT_MODE_FLAT, t('Comment paging changed.'));
+ $this->setCommentSettings('default_mode', COMMENT_MODE_FLAT, t('Comment paging changed.'));
$expected_order = array(
0,
@@ -152,7 +152,7 @@ class CommentPagerTest extends CommentTestBase {
$this->drupalGet('node/' . $node->nid);
$this->assertCommentOrder($comments, $expected_order);
- $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Switched to threaded mode.'));
+ $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, t('Switched to threaded mode.'));
$expected_order = array(
0,
@@ -234,7 +234,7 @@ class CommentPagerTest extends CommentTestBase {
// - 2
// - 5
- $this->setCommentSettings('comment_default_mode', COMMENT_MODE_FLAT, t('Comment paging changed.'));
+ $this->setCommentSettings('default_mode', COMMENT_MODE_FLAT, t('Comment paging changed.'));
$expected_pages = array(
1 => 5, // Page of comment 5
@@ -252,7 +252,7 @@ class CommentPagerTest extends CommentTestBase {
$this->assertIdentical($expected_page, $returned_page, t('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, t('Switched to threaded mode.'));
+ $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, t('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 10dc207..a755c03 100644
--- a/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php
+++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentPreviewTest.php
@@ -30,7 +30,7 @@ class CommentPreviewTest extends CommentTestBase {
$this->setCommentPreview(DRUPAL_OPTIONAL);
$this->setCommentForm(TRUE);
$this->setCommentSubject(TRUE);
- $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
+ $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
$this->drupalLogout();
// Login as web user and add a signature and a user picture.
@@ -76,7 +76,7 @@ class CommentPreviewTest extends CommentTestBase {
$this->setCommentPreview(DRUPAL_OPTIONAL);
$this->setCommentForm(TRUE);
$this->setCommentSubject(TRUE);
- $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
+ $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
$edit = array();
$edit['subject'] = $this->randomName(8);
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php
index 24d5b39..3371727 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('preview');
+ $subject_mode = config('comment.settings.article')->get('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 {
@@ -152,7 +151,7 @@ abstract class CommentTestBase extends WebTestBase {
* 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_field', ($enabled ? '1' : '0'), 'Comment subject ' . ($enabled ? 'enabled' : 'disabled') . '.');
}
/**
@@ -175,7 +174,7 @@ abstract class CommentTestBase extends WebTestBase {
$mode_text = 'required';
break;
}
- $this->setCommentSettings('comment_preview', $mode, 'Comment preview ' . $mode_text . '.');
+ $this->setCommentSettings('preview', $mode, 'Comment preview ' . $mode_text . '.');
}
/**
@@ -186,7 +185,7 @@ abstract class CommentTestBase extends WebTestBase {
* 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') . '.');
}
/**
@@ -199,7 +198,7 @@ abstract class CommentTestBase extends WebTestBase {
* - 2: Contact information required.
*/
function setCommentAnonymous($level) {
- $this->setCommentSettings('comment_anonymous', $level, 'Anonymous commenting set to level ' . $level . '.');
+ $this->setCommentSettings('anonymous', $level, 'Anonymous commenting set to level ' . $level . '.');
}
/**
@@ -209,7 +208,7 @@ abstract class CommentTestBase extends WebTestBase {
* Comments per page value.
*/
function setCommentsPerPage($number) {
- $this->setCommentSettings('comment_default_per_page', $number, 'Number of comments per page set to ' . $number . '.');
+ $this->setCommentSettings('default_per_page', $number, 'Number of comments per page set to ' . $number . '.');
}
/**
@@ -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.
}
diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentThreadingTest.php
index 1c57146..adb2c83 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 @@ class CommentThreadingTest extends CommentTestBase {
$this->setCommentPreview(DRUPAL_DISABLED);
$this->setCommentForm(TRUE);
$this->setCommentSubject(TRUE);
- $this->setCommentSettings('comment_default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
+ $this->setCommentSettings('default_mode', COMMENT_MODE_THREADED, t('Comment paging changed.'));
$this->drupalLogout();
// Create a node.
diff --git a/core/modules/node/config/node.settings.article.yml b/core/modules/node/config/node.settings.article.yml
index e69de29..a6a21a4 100644
--- a/core/modules/node/config/node.settings.article.yml
+++ b/core/modules/node/config/node.settings.article.yml
@@ -0,0 +1,8 @@
+options: ['status', 'promote']
+permissions: '1'
+type_language: '0'
+type_language_hidden: '1'
+type_language_default: 'site_default'
+type_language_translation_enabled: '0'
+submitted: '1'
+preview: '1'
diff --git a/core/modules/node/config/node.settings.page.yml b/core/modules/node/config/node.settings.page.yml
index e69de29..a6a21a4 100644
--- a/core/modules/node/config/node.settings.page.yml
+++ b/core/modules/node/config/node.settings.page.yml
@@ -0,0 +1,8 @@
+options: ['status', 'promote']
+permissions: '1'
+type_language: '0'
+type_language_hidden: '1'
+type_language_default: 'site_default'
+type_language_translation_enabled: '0'
+submitted: '1'
+preview: '1'
diff --git a/core/modules/node/config/node.settings.yml b/core/modules/node/config/node.settings.yml
index e69de29..fb2dea6 100644
--- a/core/modules/node/config/node.settings.yml
+++ b/core/modules/node/config/node.settings.yml
@@ -0,0 +1,13 @@
+node_admin_theme: '0'
+cron_last: '0'
+recent_block_count: '10'
+default_nodes_main: '10'
+vote_node_enabled: '0'
+example_restricted_roles: []
+vote_node_enabled: '1'
+vote_score_max: '5'
+access_needs_rebuild: '0'
+rank_relevance: '0'
+rank_sticky: '0'
+rank_promote: '0'
+rank_recent: '0'
diff --git a/core/modules/node/content_types.inc b/core/modules/node/content_types.inc
index 355a022..c7533f7 100644
--- a/core/modules/node/content_types.inc
+++ b/core/modules/node/content_types.inc
@@ -150,10 +150,11 @@ function node_type_form($form, &$form_state, $type = NULL) {
$form['submission']['title_label']['#description'] = t('This content type does not have a title field.');
$form['submission']['title_label']['#required'] = FALSE;
}
+ $preview = config('node.settings.' . $type->type)->get('preview');
$form['submission']['node_preview'] = array(
'#type' => 'radios',
'#title' => t('Preview before submitting'),
- '#default_value' => variable_get('node_preview_' . $type->type, DRUPAL_OPTIONAL),
+ '#default_value' => isset($preview) ? $preview : DRUPAL_OPTIONAL,
'#options' => array(
DRUPAL_DISABLED => t('Disabled'),
DRUPAL_OPTIONAL => t('Optional'),
@@ -173,9 +174,10 @@ function node_type_form($form, &$form_state, $type = NULL) {
'#collapsed' => TRUE,
'#group' => 'additional_settings',
);
+ $node_options = config('node.settings.' . $type->type)->get('options');
$form['workflow']['node_options'] = array('#type' => 'checkboxes',
'#title' => t('Default options'),
- '#default_value' => variable_get('node_options_' . $type->type, array('status', 'promote')),
+ '#default_value' => isset($node_options) ? $node_options : 'status'),
'#options' => array(
'status' => t('Published'),
'promote' => t('Promoted to front page'),
@@ -205,17 +207,19 @@ function node_type_form($form, &$form_state, $type = NULL) {
'#collapsed' => TRUE,
'#group' => 'additional_settings',
);
+ $node_type_language_default = config('node.settings.' . $type->type)->get('type_language_default');
$form['language']['node_type_language_default'] = array(
'#type' => 'select',
'#title' => t('Default language'),
'#options' => $lang_options,
- '#default_value' => variable_get('node_type_language_default_' . $type->type, 'site_default'),
+ '#default_value' => isset($node_type_language_default) ? $node_type_language_default : 'site_default',
'#description' => t('Explanation of the language options is found on the languages list page.', array('@languages_list_page' => url('admin/config/regional/language'))),
);
+ $node_type_language_hidden = config('node.settings.' . $type->type)->get('type_language_hidden');
$form['language']['node_type_language_hidden'] = array(
'#type' => 'checkbox',
'#title' => t('Hide language selector'),
- '#default_value' => variable_get('node_type_language_hidden_' . $type->type, TRUE),
+ '#default_value' => isset($node_type_language_hidden) ? $node_type_language_hidden : TRUE,
);
}
$form['display'] = array(
@@ -225,10 +229,11 @@ function node_type_form($form, &$form_state, $type = NULL) {
'#collapsed' => TRUE,
'#group' => 'additional_settings',
);
+ $node_submitted = config('node.settings.' . $type->type)->get('submitted');
$form['display']['node_submitted'] = array(
'#type' => 'checkbox',
'#title' => t('Display author and date information.'),
- '#default_value' => variable_get('node_submitted_' . $type->type, TRUE),
+ '#default_value' => isset($node_submitted) ? $node_submitted : TRUE,
'#description' => t('Author username and publish date will be displayed.'),
);
$form['old_type'] = array(
@@ -362,16 +367,19 @@ function node_type_form_submit($form, &$form_state) {
// Save or reset persistent variable values.
foreach ($variables as $key => $value) {
- $variable_new = $key . '_' . $type->type;
- $variable_old = $key . '_' . $type->old_type;
+ $config_new = config('node.settings.' . $type->type);
+ $config_old = config('node.settings.' . $type->old_type);
+
+ $variable_new = $config_new->get($key);
+ $variable_old = $config_old->get($key);
if (is_array($value)) {
$value = array_keys(array_filter($value));
}
- variable_set($variable_new, $value);
+ $config_new->set($key, $value)->save();
if ($variable_new != $variable_old) {
- variable_del($variable_old);
+ $config_old->clear($variable_old)->save();
}
}
diff --git a/core/modules/node/lib/Drupal/node/NodeFormController.php b/core/modules/node/lib/Drupal/node/NodeFormController.php
index b27e1a6..84e2cbc 100644
--- a/core/modules/node/lib/Drupal/node/NodeFormController.php
+++ b/core/modules/node/lib/Drupal/node/NodeFormController.php
@@ -25,7 +25,7 @@ class NodeFormController extends EntityFormController {
*/
protected function prepareEntity(EntityInterface $node) {
// Set up default values, if required.
- $node_options = variable_get('node_options_' . $node->type, array('status', 'promote'));
+ $node_options = config('node.settings.' . $node->type)->get('options');
// If this is a new node, fill in the default values.
if (!isset($node->nid) || isset($node->is_new)) {
foreach (array('status', 'promote', 'sticky') as $key) {
@@ -103,7 +103,7 @@ class NodeFormController extends EntityFormController {
'#type' => 'language_select',
'#default_value' => $node->langcode,
'#languages' => LANGUAGE_ALL,
- '#access' => !variable_get('node_type_language_hidden_' . $node->type, TRUE),
+ '#access' => !config('node.settings.' . $node->type)->get('type_language_hidden'),
);
$form['additional_settings'] = array(
@@ -248,7 +248,7 @@ class NodeFormController extends EntityFormController {
protected function actions(array $form, array &$form_state) {
$element = parent::actions($form, $form_state);
$node = $this->getEntity($form_state);
- $preview_mode = variable_get('node_preview_' . $node->type, DRUPAL_OPTIONAL);
+ $preview_mode = config('node.settings.' . $node->type)->get('preview');
$element['preview'] = array(
'#access' => $preview_mode != DRUPAL_DISABLED,
diff --git a/core/modules/node/lib/Drupal/node/NodeStorageController.php b/core/modules/node/lib/Drupal/node/NodeStorageController.php
index 1b1eedd..e02f3be 100644
--- a/core/modules/node/lib/Drupal/node/NodeStorageController.php
+++ b/core/modules/node/lib/Drupal/node/NodeStorageController.php
@@ -84,6 +84,7 @@ class NodeStorageController extends DatabaseStorageController {
*/
public function save(EntityInterface $entity) {
$transaction = db_transaction();
+
try {
// Load the stored entity, if any.
if (!$entity->isNew() && !isset($entity->original)) {
@@ -111,7 +112,6 @@ class NodeStorageController extends DatabaseStorageController {
$return = FALSE;
}
}
-
if ($this->revisionKey) {
$this->saveRevision($entity);
}
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php
index f7763d2..470158f 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php
@@ -101,7 +101,7 @@ class NodeCreationTest extends NodeTestBase {
*/
function testUnpublishedNodeCreation() {
// Set "Basic page" content type to be unpublished by default.
- variable_set('node_options_page', array());
+ config('node.settings.page')->set('options', array())->save();
// Set the front page to the default "node" page.
config('system.site')->set('page.front', 'node')->save();
diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php
index a73b851..91f52b5 100644
--- a/core/modules/node/node.api.php
+++ b/core/modules/node/node.api.php
@@ -380,7 +380,7 @@ function hook_node_grants_alter(&$grants, $account, $op) {
// array for roles specified in our variable setting.
// Get our list of banned roles.
- $restricted = variable_get('example_restricted_roles', array());
+ $restricted = config('node.settings')->get('example_restricted_roles');
if ($op != 'view' && !empty($restricted)) {
// Now check the roles for this account against the restrictions.
@@ -646,7 +646,7 @@ function hook_node_access($node, $op, $account, $langcode) {
*/
function hook_node_prepare(Drupal\node\Node $node) {
if (!isset($node->comment)) {
- $node->comment = variable_get("comment_$node->type", COMMENT_NODE_OPEN);
+ $node->comment = config('comment.settings.' . $node->type)->get('status');
}
}
@@ -968,7 +968,8 @@ function hook_node_info() {
*/
function hook_ranking() {
// If voting is disabled, we can avoid returning the array, no hard feelings.
- if (variable_get('vote_node_enabled', TRUE)) {
+
+ if (config('node.settings')->get('vote_node_enabled')) {
return array(
'vote_average' => array(
'title' => t('Average vote'),
@@ -979,7 +980,7 @@ function hook_ranking() {
// always 0, should be 0.
'score' => 'vote_node_data.average / CAST(%f AS DECIMAL)',
// Pass in the highest possible voting score as a decimal argument.
- 'arguments' => array(variable_get('vote_score_max', 5)),
+ 'arguments' => array(config('node.settings')->get('vote_score_max')),
),
);
}
@@ -1010,9 +1011,9 @@ function hook_node_type_insert($info) {
*/
function hook_node_type_update($info) {
if (!empty($info->old_type) && $info->old_type != $info->type) {
- $setting = variable_get('comment_' . $info->old_type, COMMENT_NODE_OPEN);
- variable_del('comment_' . $info->old_type);
- variable_set('comment_' . $info->type, $setting);
+ $setting = config('comment.settings.' . $info->old_type)->get('status');
+ config('comment.settings.' . $info->old_type)->clear('status');
+ config('comment.settings.' . $info->old_type)->set('status', $setting)->save();
}
}
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index 7add837..421e54e 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -297,7 +297,7 @@ function node_uri(Node $node) {
* Implements hook_admin_paths().
*/
function node_admin_paths() {
- if (variable_get('node_admin_theme')) {
+ if (config('node.settings')->get('node_admin_theme')) {
$paths = array(
'node/*/edit' => TRUE,
'node/*/delete' => TRUE,
@@ -680,7 +680,7 @@ function node_field_extra_fields() {
// bundle has multilingual support.
// Visibility of the ordering of the language selector is the same as on the node/add form,
// i.e. node_type_language_hidden_TYPE variable
- if ($module_language_enabled && !variable_get('node_type_language_hidden_' . $bundle->type, TRUE)) {
+ if ($module_language_enabled && !(config('node.settings.' . $bundle->type)->get('type_language_hidden'))) {
$extra['node'][$bundle->type]['form']['language'] = array(
'label' => t('Language'),
'description' => $description,
@@ -702,7 +702,7 @@ function node_field_extra_fields() {
* The language code of the node type's default langcode.
*/
function node_type_get_default_langcode($node_type) {
- $default_value = variable_get('node_type_language_default_' . $node_type, 'site_default');
+ $default_value = config('node.settings.' . $node_type)->get('type_language_default');
$language_interface = language(LANGUAGE_TYPE_INTERFACE);
@@ -1378,7 +1378,7 @@ function template_preprocess_node(&$variables) {
field_attach_preprocess('node', $node, $variables['content'], $variables);
// Display post information only on certain node types.
- if (variable_get('node_submitted_' . $node->type, TRUE)) {
+ if (config('node.settings.' . $node->type)->get('submitted')) {
$variables['display_submitted'] = TRUE;
$variables['submitted'] = t('Submitted by !username on !datetime', array('!username' => $variables['name'], '!datetime' => $variables['date']));
$variables['user_picture'] = theme_get_setting('toggle_node_user_picture') ? theme('user_picture', array('account' => $node)) : '';
@@ -1474,7 +1474,7 @@ function _node_rankings(SelectExtender $query) {
if ($ranking = module_invoke_all('ranking')) {
$tables = &$query->getTables();
foreach ($ranking as $rank => $values) {
- if ($node_rank = variable_get('node_rank_' . $rank, 0)) {
+ if ($node_rank = config('node.settings')->get('rank_' . $rank)) {
// If the table defined in the ranking isn't already joined, then add it.
if (isset($values['join']) && !isset($tables[$values['join']['alias']])) {
$query->addJoin($values['join']['type'], $values['join']['table'], $values['join']['alias'], $values['join']['on']);
@@ -1543,7 +1543,7 @@ function node_search_admin() {
'#title' => $values['title'],
'#type' => 'select',
'#options' => $options,
- '#default_value' => variable_get('node_rank_' . $var, 0),
+ '#default_value' => config('node.settings')->get('rank_' . $var),
);
}
return $form;
@@ -1639,12 +1639,12 @@ function node_ranking() {
);
// Add relevance based on creation or changed date.
- if ($node_cron_last = variable_get('node_cron_last', 0)) {
+ if ($cron_last = config('node.settings')->get('cron_last', 0)) {
$ranking['recent'] = array(
'title' => t('Recently posted'),
// Exponential decay with half-life of 6 months, starting at last indexed node
- 'score' => 'POW(2.0, (GREATEST(n.created, n.changed) - :node_cron_last) * 6.43e-8)',
- 'arguments' => array(':node_cron_last' => $node_cron_last),
+ 'score' => 'POW(2.0, (GREATEST(n.created, n.changed) - :cron_last) * 6.43e-8)',
+ 'arguments' => array(':cron_last' => $cron_last),
);
}
return $ranking;
@@ -2116,7 +2116,7 @@ function node_block_view($delta = '') {
case 'recent':
if (user_access('access content')) {
$block['subject'] = t('Recent content');
- if ($nodes = node_get_recent(variable_get('node_recent_block_count', 10))) {
+ if ($nodes = node_get_recent(config('node.settings')->get('node_recent_block_count'))) {
$block['content'] = array(
'#theme' => 'node_recent_block',
'#nodes' => $nodes,
@@ -2139,7 +2139,7 @@ function node_block_configure($delta = '') {
$form['node_recent_block_count'] = array(
'#type' => 'select',
'#title' => t('Number of recent content items to display'),
- '#default_value' => variable_get('node_recent_block_count', 10),
+ '#default_value' => config('node.settings')->get('node_recent_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)),
);
}
@@ -2151,7 +2151,7 @@ function node_block_configure($delta = '') {
*/
function node_block_save($delta = '', $edit = array()) {
if ($delta == 'recent') {
- variable_set('node_recent_block_count', $edit['node_recent_block_count']);
+ config('node.settings')->set('recent_block_count', $edit['node_recent_block_count'])->save();
}
}
@@ -2542,7 +2542,7 @@ function node_page_default() {
->orderBy('n.sticky', 'DESC')
->orderBy('n.created', 'DESC')
->extend('Drupal\Core\Database\Query\PagerSelectExtender')
- ->limit(variable_get('default_nodes_main', 10))
+ ->limit(config('node.settings')->get('default_nodes_main'))
->addTag('node_access');
$nids = $select->execute()->fetchCol();
@@ -2637,7 +2637,7 @@ function _node_index_node(Node $node) {
// Save the changed time of the most recent indexed node, for the search
// results half-life calculation.
- variable_set('node_cron_last', $node->changed);
+ config('node.settings')->get('cron_last', $node->changed)->save();
$languages = array_merge(array(language_load($node->langcode)), $node->translations());
@@ -2794,7 +2794,7 @@ function node_form_system_site_information_settings_form_alter(&$form, &$form_st
$form['front_page']['default_nodes_main'] = array(
'#type' => 'select',
'#title' => t('Number of posts on front page'),
- '#default_value' => variable_get('default_nodes_main', 10),
+ '#default_value' => config('node.settings')->get('default_nodes_main'),
'#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
'#access' => (config('system.site')->get('page.front') == 'node'),
'#description' => t('The maximum number of posts displayed on overview pages such as the front page.'),
@@ -2808,7 +2808,7 @@ function node_form_system_site_information_settings_form_alter(&$form, &$form_st
* @see node_form_system_site_information_settings_form_alter()
*/
function node_form_system_site_information_settings_form_submit($form, &$form_state) {
- variable_set('default_nodes_main', $form_state['values']['default_nodes_main']);
+ config('node.settings')->get('default_nodes_main', $form_state['values']['default_nodes_main'])->save();
}
/**
@@ -2822,7 +2822,7 @@ function node_form_system_themes_admin_form_alter(&$form, &$form_state, $form_id
$form['admin_theme']['node_admin_theme'] = array(
'#type' => 'checkbox',
'#title' => t('Use the administration theme when editing or creating content'),
- '#default_value' => variable_get('node_admin_theme', '0'),
+ '#default_value' => config('node.settings')->get('node_admin_theme'),
);
$form['#submit'][] = 'node_form_system_themes_admin_form_submit';
}
@@ -2833,7 +2833,7 @@ function node_form_system_themes_admin_form_alter(&$form, &$form_state, $form_id
* @see node_form_system_themes_admin_form_alter()
*/
function node_form_system_themes_admin_form_submit($form, &$form_state) {
- variable_set('node_admin_theme', $form_state['values']['node_admin_theme']);
+ config('node.settings')->set('node_admin_theme', $form_state['values']['node_admin_theme'])->save();
}
/**
@@ -3087,7 +3087,7 @@ function node_list_permissions($type) {
function node_permissions_get_configured_types() {
$configured_types = array();
foreach (node_type_get_types() as $name => $type) {
- if (variable_get('node_permissions_' . $name, 1)) {
+ if (config('node.settings.' . $name)->get('permissions')) {
$configured_types[$name] = $type;
}
}
@@ -3456,14 +3456,15 @@ function _node_access_write_grants(Node $node, $grants, $realm = NULL, $delete =
* The current value of the flag if no value was provided for $rebuild.
*/
function node_access_needs_rebuild($rebuild = NULL) {
+ $config = config('node.settings');
if (!isset($rebuild)) {
- return variable_get('node_access_needs_rebuild', FALSE);
+ return $config->get('access_needs_rebuild', FALSE);
}
elseif ($rebuild) {
- variable_set('node_access_needs_rebuild', TRUE);
+ $config->set('access_needs_rebuild', TRUE)->save();
}
else {
- variable_del('node_access_needs_rebuild');
+ $config->clear('access_needs_rebuild')->save();
}
}