diff --git a/core/modules/node/config/node.settings.yml b/core/modules/node/config/node.settings.yml new file mode 100644 index 0000000..42b2fb7 --- /dev/null +++ b/core/modules/node/config/node.settings.yml @@ -0,0 +1,13 @@ +admin_theme: '0' +block: + recent: + limit: '10' +default_main: '10' +example_restricted_roles: [] +access_needs_rebuild: '0' +rank: + relevance: '0' + sticky: '0' + promote: '0' + recent: '0' +cron_last: '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..46f3462 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('example.settings')->get('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('vote.settings')->get('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('vote.settings')->get('score_max')), ), ); } @@ -1010,9 +1010,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')->save(); + config('comment.settings.' . $info->type)->set('status', $setting)->save(); } } @@ -1026,7 +1026,7 @@ function hook_node_type_update($info) { * The node type object that is being deleted. */ function hook_node_type_delete($info) { - variable_del('comment_' . $info->type); + config('comment.settings.' . $info->type)->delete(); } /** diff --git a/core/modules/node/node.install b/core/modules/node/node.install index 5727129..5937c86 100644 --- a/core/modules/node/node.install +++ b/core/modules/node/node.install @@ -480,11 +480,7 @@ function node_uninstall() { variable_del('node_rank_recent'); // 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')->delete(); } /** @@ -601,6 +597,19 @@ function node_update_8004() { } /** + * Update general variables to config. + */ +function node_update_8005() { + update_variables_to_config('node.settings', array( + 'node_admin_theme' => 'admin_theme', + 'node_recent_block_count' => 'block.recent.limit', + 'default_nodes_main' => 'default_main', + 'node_access_needs_rebuild' => 'access_needs_rebuild', + 'node_cron_last' => 'cron_last', + )); +} + +/** * @} End of "addtogroup updates-7.x-to-8.x" * The next series of updates should start at 9000. */ diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 7add837..31279a9 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('admin_theme')) { $paths = array( 'node/*/edit' => TRUE, 'node/*/delete' => TRUE, @@ -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 ($node_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('block.recent.limit'))) { $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('block.recent.limit'), '#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('block.recent.limit', $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_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('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('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(); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalUpgradePathTest.php index 5956394..c44a1a8 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/BareMinimalUpgradePathTest.php @@ -36,7 +36,7 @@ class BareMinimalUpgradePathTest extends UpgradePathTestBase { * Tests a successful major version release upgrade. */ public function testBasicMinimalUpgrade() { - $this->assertTrue($this->performUpgrade(), t('The upgrade was completed successfully.')); + $this->assertTrue($this->performUpgrade(TRUE), t('The upgrade was completed successfully.')); // Ensure that the new Entity module is enabled after upgrade. $this->assertTrue(module_exists('entity'), 'Entity module enabled after upgrade.');