diff --git a/core/modules/book/book.install b/core/modules/book/book.install
index 2293c46..3b3f4de 100644
--- a/core/modules/book/book.install
+++ b/core/modules/book/book.install
@@ -43,7 +43,7 @@ function _book_install_type_create() {
node_type_save($book_node_type);
node_add_body_field($book_node_type);
// Default to not promoted.
- variable_set('node_options_book', array('status'));
+ config('node.type.settings')->set('book.options', array('status'));
}
/**
diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php
index 5ad396a..e181399 100644
--- a/core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php
+++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php
@@ -36,7 +36,7 @@ class ForumNodeAccessTest extends WebTestBase {
function setUp() {
parent::setUp();
node_access_rebuild();
- variable_set('node_access_test_private', TRUE);
+ config('node_access_test.settings')->set('node_access_test_private', TRUE)->save();
}
/**
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php
index 7591f67..3587f3a 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUninstallTest.php
@@ -63,7 +63,7 @@ class LocaleUninstallTest extends WebTestBase {
$this->assertEqual(language(LANGUAGE_TYPE_INTERFACE)->langcode, $this->langcode, t('Current language: %lang', array('%lang' => language(LANGUAGE_TYPE_INTERFACE)->langcode)));
// Enable multilingual workflow option for articles.
- variable_set('node_type_language_hidden_article',FALSE);
+ config('node.type.settings')->set('article.type_language_hidden', FALSE)->save();
// Change JavaScript translations directory.
variable_set('locale_js_directory', 'js_translations');
// Build the JavaScript translation file for French.
diff --git a/core/modules/node/config/node.settings.yml b/core/modules/node/config/node.settings.yml
new file mode 100644
index 0000000..bbc52ef
--- /dev/null
+++ b/core/modules/node/config/node.settings.yml
@@ -0,0 +1,11 @@
+admin_theme: '0'
+block:
+ recent:
+ limit: '10'
+default_main: '10'
+access_needs_rebuild: '0'
+rank:
+ relevance: '0'
+ sticky: '0'
+ promote: '0'
+ recent: '0'
diff --git a/core/modules/node/content_types.inc b/core/modules/node/content_types.inc
index 355a022..49a6870 100644
--- a/core/modules/node/content_types.inc
+++ b/core/modules/node/content_types.inc
@@ -91,7 +91,7 @@ function node_type_form($form, &$form_state, $type = NULL) {
// This is a new type. Node module managed types are custom and unlocked.
$type = node_type_set_defaults(array('custom' => 1, 'locked' => 0));
}
-
+ $config = config('node.type.settings');
// Make the type object available to implementations of hook_form_alter.
$form['#node_type'] = $type;
@@ -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->get($type->type . '.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',
);
+ $options = $config->get($type->type . '.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($options) ? $options : array('status', 'promote'),
'#options' => array(
'status' => t('Published'),
'promote' => t('Promoted to front page'),
@@ -205,17 +207,20 @@ function node_type_form($form, &$form_state, $type = NULL) {
'#collapsed' => TRUE,
'#group' => 'additional_settings',
);
+ $language_default = $config->get($type->type .'.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' => $language_default != 'site_default' ? $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'))),
);
+ $language_hidden = $config->get($type->type .'.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' => $language_hidden == '1' ? TRUE : FALSE,
);
}
$form['display'] = array(
@@ -225,10 +230,11 @@ function node_type_form($form, &$form_state, $type = NULL) {
'#collapsed' => TRUE,
'#group' => 'additional_settings',
);
+ $submitted = $config->get($type->type . '.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' => $submitted == 1 ? TRUE : FALSE,
'#description' => t('Author username and publish date will be displayed.'),
);
$form['old_type'] = array(
@@ -361,16 +367,25 @@ function node_type_form_submit($form, &$form_state) {
unset($variables['form_token'], $variables['op'], $variables['submit'], $variables['delete'], $variables['reset'], $variables['form_id'], $variables['form_build_id']);
// Save or reset persistent variable values.
+ // we keep some variable_set for menu and comment modules
+ // until they get converted.
+ $config = config('node.type.settings');
foreach ($variables as $key => $value) {
+ // for config
+ $configvariable_new = $type->type . '.' . str_replace('node_', '', $key);
+ $configvariable_old = $type->old_type . '.' . str_replace('node_', '', $key);
+ // for variable_set
$variable_new = $key . '_' . $type->type;
$variable_old = $key . '_' . $type->old_type;
if (is_array($value)) {
$value = array_keys(array_filter($value));
}
+ $config->set($configvariable_new , $value)->save();
variable_set($variable_new, $value);
if ($variable_new != $variable_old) {
+ $config->clear($variable_old)->save();
variable_del($variable_old);
}
}
@@ -466,6 +481,7 @@ function node_type_delete_confirm($form, &$form_state, $type) {
function node_type_delete_confirm_submit($form, &$form_state) {
node_type_delete($form_state['values']['type']);
+ config('node.type.settings')->clear($form_state['values']['type'] . '.preview')->save();
variable_del('node_preview_' . $form_state['values']['type']);
$t_args = array('%name' => $form_state['values']['name']);
drupal_set_message(t('The content type %name has been deleted.', $t_args));
diff --git a/core/modules/node/lib/Drupal/node/NodeFormController.php b/core/modules/node/lib/Drupal/node/NodeFormController.php
index b9bf7eb..455acef 100644
--- a/core/modules/node/lib/Drupal/node/NodeFormController.php
+++ b/core/modules/node/lib/Drupal/node/NodeFormController.php
@@ -25,7 +25,11 @@ 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.type.settings')->get($node->type . '.options');
+
+ if (!is_array(config('node.type.settings')->get($node->type . '.options'))) {
+ $node_options = array('status', 'promote');
+ }
// 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 +107,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.type.settings')->get($node->type . '.type_language_hidden') == '1' ? FALSE : TRUE,
);
$form['additional_settings'] = array(
@@ -248,7 +252,8 @@ 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_type = config('node.type.settings')->get($node->type . '.preview');
+ $preview_mode = isset($preview_type) ? $preview_type : DRUPAL_OPTIONAL;
$element['preview'] = array(
'#access' => $preview_mode != DRUPAL_DISABLED,
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php
index e5253a8..8349f7f 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php
@@ -37,7 +37,7 @@ class NodeAccessBaseTableTest extends NodeTestBase {
parent::setUp();
node_access_rebuild();
- variable_set('node_access_test_private', TRUE);
+ config('node_access_test.settings')->set('node_access_test_private', TRUE)->save();
}
/**
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php
index 7de9d74..d3a7d34 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php
@@ -80,7 +80,7 @@ class NodeAccessLanguageTest extends NodeTestBase {
// Reset the node access cache and turn on our test node_access() code.
drupal_static_reset('node_access');
- variable_set('node_access_test_secret_catalan', 1);
+ config('node_access_test.settings')->set('node_access_test_secret_catalan', 1)->save();
// Tests that Hungarian is still accessible.
$this->assertNodeAccess($expected_node_access, $node, $web_user, 'hu');
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/lib/Drupal/node/Tests/NodeCreationTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeCreationTest.php
index f7763d2..a259214 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.type.settings')->set('page.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/lib/Drupal/node/Tests/NodeQueryAlterTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php
index 1f367cf..9acecd6 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeQueryAlterTest.php
@@ -196,7 +196,7 @@ class NodeQueryAlterTest extends NodeTestBase {
// $account instead of the global $user, we will log in as
// noAccessUser2.
$this->drupalLogin($this->noAccessUser2);
- variable_set('node_test_node_access_all_uid', $this->noAccessUser->uid);
+ config('node_access_test.settings')->set('node_test_node_access_all_uid', $this->noAccessUser->uid)->save();
drupal_static_reset('node_access_view_all_nodes');
try {
$query = db_select('node', 'mytab')
@@ -211,6 +211,6 @@ class NodeQueryAlterTest extends NodeTestBase {
catch (Exception $e) {
$this->fail(t('Altered query is malformed'));
}
- variable_del('node_test_node_access_all_uid');
+ config('node_access_test.settings')->clear('node_test_node_access_all_uid')->save();
}
}
diff --git a/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php b/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php
index 5bfd342..cb3dc99 100644
--- a/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php
@@ -55,8 +55,7 @@ class PagePreviewTest extends NodeTestBase {
$title_key = "title";
$body_key = "body[$langcode][0][value]";
// Force revision on "Basic page" content.
- variable_set('node_options_page', array('status', 'revision'));
-
+ config('node.type.settings')->set('page.options', array('status', 'revision'))->save();
// Fill in node creation form and preview node.
$edit = array();
$edit[$title_key] = $this->randomName(8);
diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php
index 2daa954..5f8e1d3 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.
@@ -971,7 +971,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'),
@@ -982,7 +982,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')),
),
);
}
diff --git a/core/modules/node/node.install b/core/modules/node/node.install
index 5727129..97fa0c9 100644
--- a/core/modules/node/node.install
+++ b/core/modules/node/node.install
@@ -472,19 +472,8 @@ function node_uninstall() {
->execute();
}
- // 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');
-
// 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();
}
/**
@@ -558,9 +547,11 @@ function node_update_8003() {
$types = db_query('SELECT type FROM {node_type}')->fetchCol();
foreach ($types as $type) {
update_variable_set('node_type_language_default_' . $type, LANGUAGE_NOT_SPECIFIED);
+ config('node.type.settings')->set($type . '.type_language_default', LANGUAGE_NOT_SPECIFIED)->save();
$node_type_language = update_variable_get('node_type_language_' . $type, 0);
if ($node_type_language == 0) {
update_variable_set('node_type_language_hidden_' . $type, TRUE);
+ config('node.type.settings')->set($type . '.type_language_hidden', TRUE)->save();
}
if ($node_type_language == 2) {
// Translation was enabled, so enable it again and
@@ -569,6 +560,8 @@ function node_update_8003() {
// cannot be enabled.
update_variable_set('node_type_language_hidden_' . $type, FALSE);
update_variable_set('node_type_language_translation_enabled_' . $type, TRUE);
+ config('node.type.settings')->set($type . '.type_language_hidden', FALSE)->save();
+ config('node.type.settings')->set($type . '.type_language_translation_enabled', TRUE)->save();
}
update_variable_del('node_type_language_' . $type);
}
@@ -601,6 +594,24 @@ function node_update_8004() {
}
/**
+ * Update general variables to config.
+ */
+function node_update_8005() {
+ $variables = 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_ranks = db_query("SELECT DISTINCT name FROM {variable} where name like 'node_rank_%'")->fetchCol();
+ foreach ($node_ranks as $rank) {
+ $variables[$rank] = 'rank.' . str_replace('node_rank_', '', $rank);
+ }
+ update_variables_to_config('node.settings', $variables);
+}
+
+/**
* @} 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 573d286..69bfa1d 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,
@@ -565,7 +565,20 @@ function node_type_save($info) {
$existing_type = !empty($info->old_type) ? $info->old_type : $info->type;
$is_existing = (bool) db_query_range('SELECT 1 FROM {node_type} WHERE type = :type', 0, 1, array(':type' => $existing_type))->fetchField();
$type = node_type_set_defaults($info);
-
+ // Set some default config variables
+ // if it is created programatically
+ // should be removed when the node config object
+ // issue is finished.
+ // see http://drupal.org/node/111715
+ if (!config('node.type.settings')->get($type->type . '.permissions')) {
+ config('node.type.settings')->set($type->type . '.permissions', 1)->save();
+ config('node.type.settings')->set($type->type . '.submitted', 1)->save();
+ config('node.type.settings')->set($type->type . '.preview', 1)->save();
+ config('node.type.settings')->set($type->type . '.options', array('status', 'promote'))->save();
+ config('node.type.settings')->set($type->type . '.type_language_default', 'site_default')->save();
+ config('node.type.settings')->set($type->type . '.type_language_hidden', 1)->save();
+ config('node.type.settings')->set($type->type . '.type_language_translation_enabled', 0)->save();
+ }
$fields = array(
'type' => (string) $type->type,
'name' => (string) $type->name,
@@ -680,7 +693,9 @@ function node_field_extra_fields() {
// 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) {
- if (!variable_get('node_type_language_hidden_' . $bundle->type, TRUE)) {
+ $type_language = config('node.type.settings')->get($bundle->type . '.type_language_hidden');
+ $language_enable = $type_language != 0 ? $type_language : FALSE;
+ if ($module_language_enabled && !$language_enable) {
$extra['node'][$bundle->type]['form']['language'] = array(
'label' => t('Language'),
'description' => $description,
@@ -709,7 +724,8 @@ 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');
+ $value = config('node.type.settings')->get($node_type . '.type_language_default');
+ $default_value = isset($value) ? $value : 'site_default';
$language_interface = language(LANGUAGE_TYPE_INTERFACE);
@@ -1395,7 +1411,9 @@ 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)) {
+ $type_submitted = config('node.type.settings')->get($node->type . '.submitted');
+ $submitted = isset($type_submitted) ? $type_submitted : TRUE;
+ if ($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)) : '';
@@ -1491,7 +1509,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']);
@@ -1556,11 +1574,11 @@ function node_search_admin() {
// Note: reversed to reflect that higher number = higher ranking.
$options = drupal_map_assoc(range(0, 10));
foreach (module_invoke_all('ranking') as $var => $values) {
- $form['content_ranking']['factors']['node_rank_' . $var] = array(
+ $form['content_ranking']['factors']['rank.' . $var] = array(
'#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;
@@ -1656,7 +1674,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 = state()->get('node_cron_last')) {
$ranking['recent'] = array(
'title' => t('Recently posted'),
// Exponential decay with half-life of 6 months, starting at last indexed node
@@ -2133,7 +2151,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,
@@ -2153,10 +2171,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)),
);
}
@@ -2168,7 +2186,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();
}
}
@@ -2559,7 +2577,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();
@@ -2654,7 +2672,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);
+ state()->set('node_cron_last', $node->changed);
$languages = array_merge(array(language_load($node->langcode)), $node->translations());
@@ -2811,7 +2829,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_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.'),
@@ -2825,7 +2843,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_main', $form_state['values']['default_nodes_main'])->save();
}
/**
@@ -2839,7 +2857,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';
}
@@ -2850,7 +2868,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();
}
/**
@@ -3104,7 +3122,8 @@ 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)) {
+ $permissions = config('node.type.settings')->get($name . '.permissions') == 0 ? FALSE : TRUE;
+ if ($permissions) {
$configured_types[$name] = $type;
}
}
@@ -3474,13 +3493,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/node/tests/modules/node_access_test/config/node_access_test.settings.yml b/core/modules/node/tests/modules/node_access_test/config/node_access_test.settings.yml
new file mode 100644
index 0000000..4e7f745
--- /dev/null
+++ b/core/modules/node/tests/modules/node_access_test/config/node_access_test.settings.yml
@@ -0,0 +1,3 @@
+node_test_node_access_all_uid: '0'
+node_access_test_secret_catalan: '0'
+node_access_test_private: '0'
diff --git a/core/modules/node/tests/modules/node_access_test/node_access_test.module b/core/modules/node/tests/modules/node_access_test/node_access_test.module
index a503217..477c39d 100644
--- a/core/modules/node/tests/modules/node_access_test/node_access_test.module
+++ b/core/modules/node/tests/modules/node_access_test/node_access_test.module
@@ -21,7 +21,7 @@ function node_access_test_node_grants($account, $op) {
if ($op == 'view' && user_access('node test view', $account)) {
$grants['node_access_test'] = array(8888, 8889);
}
- if ($op == 'view' && $account->uid == variable_get('node_test_node_access_all_uid', 0)) {
+ if ($op == 'view' && $account->uid == config('node_access_test.settings')->get('node_test_node_access_all_uid')) {
$grants['node_access_all'] = array(0);
}
return $grants;
@@ -33,7 +33,7 @@ function node_access_test_node_grants($account, $op) {
function node_access_test_node_access_records(Node $node) {
$grants = array();
// For NodeAccessBaseTableTestCase, only set records for private nodes.
- if (!variable_get('node_access_test_private') || $node->private) {
+ if (!config('node_access_test.settings')->get('node_access_test_private') || $node->private) {
$grants[] = array(
'realm' => 'node_access_test',
'gid' => 8888,
@@ -179,7 +179,7 @@ function node_access_entity_test_page() {
*/
function node_access_test_form_node_form_alter(&$form, $form_state) {
// Only show this checkbox for NodeAccessBaseTableTestCase.
- if (variable_get('node_access_test_private')) {
+ if (config('node_access_test.settings')->get('node_access_test_private')) {
$node = $form_state['controller']->getEntity($form_state);
$form['private'] = array(
'#type' => 'checkbox',
@@ -238,7 +238,7 @@ function _node_access_test_node_write(Node $node) {
* Implements hook_node_access().
*/
function node_access_test_node_access($node, $op, $account, $langcode) {
- if (variable_get('node_access_test_secret_catalan', 0) && $langcode == 'ca') {
+ if (config('node_access_test.settings')->get('node_access_test_secret_catalan') && $langcode == 'ca') {
// Make all Catalan content secret.
return NODE_ACCESS_DENY;
}
diff --git a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php
index f9aa0de..98aed95 100644
--- a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php
+++ b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php
@@ -50,8 +50,8 @@ class PathLanguageTest extends PathTestBase {
*/
function testAliasTranslation() {
// Set 'page' content type to enable translation.
- variable_set('node_type_language_hidden_page', FALSE);
- variable_set('node_type_language_translation_enabled_page', TRUE);
+ config('node.type.settings')->set('page.type_language_hidden', FALSE)->save();
+ config('node.type.settings')->set('page.type_language_translation_enabled', TRUE)->save();
$english_node = $this->drupalCreateNode(array('type' => 'page'));
$english_alias = $this->randomName();
diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php
index a57e483..d5051a7 100644
--- a/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php
+++ b/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php
@@ -93,7 +93,7 @@ class SearchRankingTest extends SearchTestBase {
foreach ($node_ranks as $node_rank) {
// Disable all relevancy rankings except the one we are testing.
foreach ($node_ranks as $var) {
- variable_set('node_rank_' . $var, $var == $node_rank ? 10 : 0);
+ config('node.settings')->set('rank.' . $var, $var == $node_rank ? 10 : 0)->save();
}
// Do the search and assert the results.
diff --git a/core/modules/search/search.api.php b/core/modules/search/search.api.php
index 3dcea0d..9ad1dae 100644
--- a/core/modules/search/search.api.php
+++ b/core/modules/search/search.api.php
@@ -148,7 +148,7 @@ function hook_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;
@@ -359,7 +359,7 @@ function hook_update_index() {
// Save the changed time of the most recent indexed node, for the search
// results half-life calculation.
- variable_set('node_cron_last', $node->changed);
+ state()->set('node_cron_last', $node->changed);
// Render the node.
node_build_content($node, 'search_index');
diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php
index 9ee094b..b393bd4 100644
--- a/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php
+++ b/core/modules/shortcut/lib/Drupal/shortcut/Tests/ShortcutLinksTest.php
@@ -65,7 +65,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
function testShortcutQuickLink() {
theme_enable(array('seven'));
variable_set('admin_theme', 'seven');
- variable_set('node_admin_theme', TRUE);
+ config('node.settings')->set('admin_theme', TRUE)->save();
$this->drupalGet($this->set->links[0]['link_path']);
$this->assertRaw(t('Remove from %title shortcuts', array('%title' => $this->set->title)), '"Add to shortcuts" link properly switched to "Remove from shortcuts".');
}
diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php
index 7a30cb0..85852ec 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php
@@ -35,6 +35,7 @@ class LanguageUpgradePathTest extends UpgradePathTestBase {
* Tests a successful upgrade.
*/
public function testLanguageUpgrade() {
+ config('node.type.settings')->set('page.type_language_hidden', '1')->save();
db_update('users')->fields(array('language' => 'ca'))->condition('uid', '1')->execute();
$this->assertTrue($this->performUpgrade(), t('The upgrade was completed successfully.'));
diff --git a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php
index 3a5efda..d831414 100644
--- a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php
+++ b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php
@@ -35,7 +35,7 @@ class TrackerNodeAccessTest extends WebTestBase {
public function setUp() {
parent::setUp();
node_access_rebuild();
- variable_set('node_access_test_private', TRUE);
+ config('node_access_test.settings')->set('node_access_test_private', TRUE)->save();
}
diff --git a/core/modules/translation/translation.module b/core/modules/translation/translation.module
index bf1e528..f0d8603 100644
--- a/core/modules/translation/translation.module
+++ b/core/modules/translation/translation.module
@@ -93,7 +93,7 @@ function _translation_tab_access($node) {
* Implements hook_admin_paths().
*/
function translation_admin_paths() {
- if (variable_get('node_admin_theme')) {
+ if (config('node.settings')->get('admin_theme')) {
$paths = array(
'node/*/translate' => TRUE,
);
@@ -160,7 +160,7 @@ function translation_form_node_type_form_alter(&$form, &$form_state) {
$form['language']['node_type_language_translation_enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Enable translation'),
- '#default_value' => variable_get('node_type_language_translation_enabled_' . $form['#node_type']->type, FALSE),
+ '#default_value' => config('node.type.settings')->get($form['#node_type']->type . '.type_language_translation_enabled') == 0 ? FALSE : TRUE,
'#element_validate' => array('translation_node_type_language_translation_enabled_validate'),
'#prefix' => "",
);
@@ -507,7 +507,9 @@ function translation_node_get_translations($tnid) {
* TRUE if translation is supported, and FALSE if not.
*/
function translation_supported_type($type) {
- return variable_get('node_type_language_translation_enabled_' . $type, FALSE);
+ $value = config('node.type.settings')->get($type . '.type_language_translation_enabled');
+ $translation_enabled = isset($value) ? $value : FALSE;
+ return $translation_enabled;
}
/**
diff --git a/core/profiles/standard/standard.install b/core/profiles/standard/standard.install
index 5b74b51..70dd17f 100644
--- a/core/profiles/standard/standard.install
+++ b/core/profiles/standard/standard.install
@@ -237,11 +237,11 @@ function standard_install() {
}
// Default "Basic page" to not be promoted and have comments disabled.
- variable_set('node_options_page', array('status'));
+ config('node.type.settings')->set('page.options', array('status'))->save();
variable_set('comment_page', COMMENT_NODE_HIDDEN);
// Don't display date and author information for "Basic page" nodes by default.
- variable_set('node_submitted_page', FALSE);
+ config('node.type.settings')->set('page.submitted', FALSE)->save();
// Enable user picture support and set the default to a square thumbnail option.
variable_set('user_pictures', '1');
@@ -421,5 +421,5 @@ function standard_install() {
// Enable the admin theme.
theme_enable(array('seven'));
variable_set('admin_theme', 'seven');
- variable_set('node_admin_theme', '1');
+ config('node.settings')->set('admin_theme', 1)->save();
}