diff --git a/core/modules/node/config/node.settings.yml b/core/modules/node/config/node.settings.yml new file mode 100644 index 0000000..f8fbf11 --- /dev/null +++ b/core/modules/node/config/node.settings.yml @@ -0,0 +1,12 @@ +node_admin_theme: '0' +cron_last: '0' +recent_block_count: '10' +default_nodes_main: '10' +vote_node_enabled: '0' +example_restricted_roles: [] +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/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php index 0c86de2..cdb327a 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php @@ -56,7 +56,7 @@ class NodeBlockFunctionalTest extends NodeTestBase { // Set block title and variables. $block = array( 'title' => $this->randomName(), - 'node_recent_block_count' => 2, + 'recent_block_count' => 2, ); $this->drupalPost('admin/structure/block/manage/node/recent/configure', $block, t('Save block')); $this->assertText(t('The block configuration has been saved.'), t('Block saved.')); @@ -104,7 +104,7 @@ class NodeBlockFunctionalTest extends NodeTestBase { $this->drupalLogout(); $this->drupalLogin($this->admin_user); $block = array( - 'node_recent_block_count' => 10, + 'recent_block_count' => 10, ); $this->drupalPost('admin/structure/block/manage/node/recent/configure', $block, t('Save block')); $this->assertText(t('The block configuration has been saved.'), t('Block saved.')); diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php index a73b851..8c4aa66 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. @@ -968,7 +968,7 @@ 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 +979,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')), ), ); } diff --git a/core/modules/node/node.install b/core/modules/node/node.install index 5727129..e2fbc44 100644 --- a/core/modules/node/node.install +++ b/core/modules/node/node.install @@ -474,17 +474,17 @@ function node_uninstall() { // Delete node search ranking variables. // @see node_ranking(), _node_rankings() - variable_del('node_rank_relevance'); - variable_del('node_rank_sticky'); - variable_del('node_rank_promote'); - variable_del('node_rank_recent'); + config('node.settings')->clear('rank_relevance')->save(); + config('node.settings')->clear('rank_sticky')->save(); + config('node.settings')->clear('rank_promote')->save(); + config('node.settings')->clear('rank_recent')->save(); // Delete remaining general module variables. - variable_del('node_access_needs_rebuild'); - variable_del('node_admin_theme'); - variable_del('node_cron_last'); - variable_del('node_recent_block_count'); - variable_del('default_nodes_main'); + config('node.settings')->clear('node_admin_theme')->save(); + config('node.settings')->clear('cron_last')->save(); + config('node.settings')->clear('recent_block_count')->save(); + config('node.settings')->clear('default_nodes_main')->save(); + config('node.settings')->clear('access_needs_rebuild')->save(); } /** diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 7add837..0286450 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, @@ -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,7 +1639,7 @@ 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')) { $ranking['recent'] = array( 'title' => t('Recently posted'), // Exponential decay with half-life of 6 months, starting at last indexed node @@ -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('recent_block_count'))) { $block['content'] = array( '#theme' => 'node_recent_block', '#nodes' => $nodes, @@ -2136,10 +2136,10 @@ function node_block_view($delta = '') { function node_block_configure($delta = '') { $form = array(); if ($delta == 'recent') { - $form['node_recent_block_count'] = array( + $form['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('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['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')->set('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')->set('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(); } /** @@ -3457,13 +3457,13 @@ function _node_access_write_grants(Node $node, $grants, $realm = NULL, $delete = */ function node_access_needs_rebuild($rebuild = NULL) { if (!isset($rebuild)) { - return variable_get('node_access_needs_rebuild', FALSE); + return config('node.settings')->get('access_needs_rebuild'); } elseif ($rebuild) { - variable_set('node_access_needs_rebuild', TRUE); + config('node.settings')->set('access_needs_rebuild', TRUE)->save(); } else { - variable_del('node_access_needs_rebuild'); + config('node.settings')->clear('access_needs_rebuild')->save(); } }