diff --git a/core/modules/edit/lib/Drupal/edit/Tests/EditTestBase.php b/core/modules/edit/lib/Drupal/edit/Tests/EditTestBase.php index 7aef8c5..8bb90e4 100644 --- a/core/modules/edit/lib/Drupal/edit/Tests/EditTestBase.php +++ b/core/modules/edit/lib/Drupal/edit/Tests/EditTestBase.php @@ -13,7 +13,6 @@ * Parent class for Edit tests. */ class EditTestBase extends DrupalUnitTestBase { - var $default_storage = 'field_sql_storage'; /** * Modules to enable. @@ -30,6 +29,7 @@ function setUp() { $this->installSchema('system', 'variable'); $this->installSchema('field', array('field_config', 'field_config_instance')); $this->installSchema('entity_test', array('entity_test', 'entity_test_rev')); + $this->installConfig(array('field')); } /** diff --git a/core/modules/field/config/field.settings.yml b/core/modules/field/config/field.settings.yml index 51cf519..51c0fee 100644 --- a/core/modules/field/config/field.settings.yml +++ b/core/modules/field/config/field.settings.yml @@ -1,2 +1,3 @@ purge_batch_size: 10 -storage_default: field_sql_storage +default_storage: field_sql_storage +language_fallback: false diff --git a/core/modules/field/field.api.php b/core/modules/field/field.api.php index 3404ce8..0973280 100644 --- a/core/modules/field/field.api.php +++ b/core/modules/field/field.api.php @@ -1133,7 +1133,7 @@ function hook_field_attach_prepare_translation_alter(\Drupal\Core\Entity\EntityI function hook_field_language_alter(&$display_langcode, $context) { // Do not apply core language fallback rules if they are disabled or if Locale // is not registered as a translation handler. - if (state()->get('field.language_fallback') && field_has_translation_handler($context['entity']->entityType())) { + if (config('field.settings')->get('language_fallback') && field_has_translation_handler($context['entity']->entityType())) { field_language_fallback($display_langcode, $context['entity'], $context['langcode']); } } @@ -1189,13 +1189,14 @@ function hook_field_attach_create_bundle($entity_type, $bundle) { * The new name of the bundle. */ function hook_field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) { - // Update the extra weights variable with new information. + // Update the settings associated with the bundle in my_module.settings. if ($bundle_old !== $bundle_new) { - $extra_weights = config('field.settings')->get('extra_weights'); - if (isset($info[$entity_type][$bundle_old])) { - $extra_weights[$entity_type][$bundle_new] = $extra_weights[$entity_type][$bundle_old]; - unset($extra_weights[$entity_type][$bundle_old]); - config('field.settings')->set('extra_weights', $extra_weights)->save(); + $config = config('my_module.settings'); + $bundle_settings = $config->get('bundle_settings'); + if (isset($bundle_settings[$entity_type][$bundle_old])) { + $bundle_settings[$entity_type][$bundle_new] = $bundle_settings[$entity_type][$bundle_old]; + unset($bundle_setting[$entity_type][$bundle_old]); + $config->set('bundle_settings', $bundle_settings); } } } @@ -1214,11 +1215,12 @@ function hook_field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) * deleted. */ function hook_field_attach_delete_bundle($entity_type, $bundle, $instances) { - // Remove the extra weights variable information for this bundle. - $extra_weights = config('field.settings')->get('extra_weights'); - if (isset($extra_weights[$entity_type][$bundle])) { - unset($extra_weights[$entity_type][$bundle]); - config('field.settings')->set('extra_weights', $extra_weights)->save(); + // Remove the settings associated with the bundle in my_module.settings. + $config = config('my_module.settings'); + $bundle_settings = $config->get('bundle_settings'); + if (isset($bundle_settings[$entity_type][$bundle])) { + unset($bundle_setting[$entity_type][$bundle]); + $config->set('bundle_settings', $bundle_settings); } } diff --git a/core/modules/field/field.attach.inc b/core/modules/field/field.attach.inc index 4da6d28..1124fb9 100644 --- a/core/modules/field/field.attach.inc +++ b/core/modules/field/field.attach.inc @@ -23,7 +23,7 @@ * such as a cloud-based database. * * Each field defines which storage backend it uses. The Drupal configuration - * 'field.settings.storage_default' identifies the storage backend used by + * 'field.settings.default_storage' identifies the storage backend used by * default. * * See @link field Field API @endlink for information about the other parts of diff --git a/core/modules/field/field.crud.inc b/core/modules/field/field.crud.inc index cb16cc3..5700ebc 100644 --- a/core/modules/field/field.crud.inc +++ b/core/modules/field/field.crud.inc @@ -44,7 +44,7 @@ * hook_field_info(). * - storage: * - type: the storage backend specified in the - * 'field.settings.storage_default' configuration. + * 'field.settings.default_storage' configuration. * - settings: each omitted setting is given the default value specified in * hook_field_storage_info(). * @@ -119,7 +119,7 @@ function field_create_field($field) { // Provide default storage. $field['storage'] += array( - 'type' => config('field.settings')->get('storage_default'), + 'type' => config('field.settings')->get('default_storage'), 'settings' => array(), ); // Check that the storage type is known. diff --git a/core/modules/field/field.install b/core/modules/field/field.install index 47eebe3..f68540c 100644 --- a/core/modules/field/field.install +++ b/core/modules/field/field.install @@ -490,12 +490,9 @@ function field_update_8002() { */ function field_update_8003() { update_variables_to_config('field.settings', array( - 'field_storage_default' => 'storage_default', + 'field_storage_default' => 'default_storage', + 'field_language_fallback' => 'language_fallback', )); - if (variable_get('language_count', 1) >= 1) { - state()->set('field.language_fallback', TRUE); - } - update_variable_del('field_language_fallback'); } /** diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 74edf5c..407abe4 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -468,7 +468,8 @@ function field_entity_field_info($entity_type) { * otherwise all the fallback candidates are inspected to see if there is a * field translation available in another language. * By default this is called by field_field_language_alter(), but this - * behavior can be disabled by setting 'field.language_fallback' to FALSE. + * behavior can be disabled by setting the 'field.settings.language_fallback' + * variable to FALSE. * * @param $field_langcodes * A reference to an array of language codes keyed by field name. diff --git a/core/modules/field/field.multilingual.inc b/core/modules/field/field.multilingual.inc index 88cf1a1..2f521ce 100644 --- a/core/modules/field/field.multilingual.inc +++ b/core/modules/field/field.multilingual.inc @@ -73,7 +73,7 @@ function field_language_insert() { // Because the language_count is updated only after the hook is invoked, we // check if the language_count is bigger or equal with 1 at the current time. if (variable_get('language_count', 1) >= 1) { - state()->set('field.language_fallback', TRUE); + config('field.settings')->set('language_fallback', TRUE); } } @@ -94,7 +94,7 @@ function field_language_delete() { // Because the language_count is updated after the hook is invoked, we check // if the language_count is less or equal with 2 at the current time. if (variable_get('language_count', 1) <= 2) { - state()->set('field.language_fallback', FALSE); + config('field.settings')->set('language_fallback', FALSE); } } @@ -317,7 +317,7 @@ function field_language(EntityInterface $entity, $field_name = NULL, $langcode = ); // Do not apply core language fallback rules if they are disabled or if // the entity does not have a translation handler registered. - if (state()->get('field.language_fallback') && field_has_translation_handler($entity_type)) { + if (config('field.settings')->get('language_fallback') && field_has_translation_handler($entity_type)) { field_language_fallback($display_langcode, $context['entity'], $context['langcode']); } drupal_alter('field_language', $display_langcode, $context); diff --git a/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php index ffb1292..f2d40a7 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php +++ b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php @@ -196,7 +196,7 @@ public function query($use_groupby = FALSE) { $this->view->display_handler->options['field_langcode']); $placeholder = $this->placeholder(); $langcode_fallback_candidates = array($langcode); - if (state()->get('field.language_fallback')) { + if (config('field.settings')->get('language_fallback')) { require_once DRUPAL_ROOT . '/includes/language.inc'; $langcode_fallback_candidates = array_merge($langcode_fallback_candidates, language_fallback_get_candidates()); } diff --git a/core/modules/field/lib/Drupal/field/Tests/CrudTest.php b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php index 69d3cb3..f68ee8f 100644 --- a/core/modules/field/lib/Drupal/field/Tests/CrudTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php @@ -62,7 +62,7 @@ function testCreateField() { $this->assertIdentical($record['data']['settings'], $field_type['settings'], 'Default field settings have been written.'); // Ensure that default storage was set. - $this->assertEqual($record['storage_type'], config('field.settings')->get('storage_default'), 'The field type is properly saved.'); + $this->assertEqual($record['storage_type'], config('field.settings')->get('default_storage'), 'The field type is properly saved.'); // Guarantee that the name is unique. try { diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldTestBase.php b/core/modules/field/lib/Drupal/field/Tests/FieldTestBase.php index ee10301..3944639 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldTestBase.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldTestBase.php @@ -14,17 +14,6 @@ * Parent class for Field API tests. */ abstract class FieldTestBase extends WebTestBase { - var $default_storage = 'field_sql_storage'; - - /** - * Set the default field storage backend for fields created during tests. - */ - function setUp() { - parent::setUp(); - - // Set default storage backend. - config('field.settings')->set('storage_default', $this->default_storage)->save(); - } /** * Generate random values for a field_test field. diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldUnitTestBase.php b/core/modules/field/lib/Drupal/field/Tests/FieldUnitTestBase.php index ec47261..9ed0a22 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldUnitTestBase.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldUnitTestBase.php @@ -14,7 +14,6 @@ * Parent class for Field API unit tests. */ abstract class FieldUnitTestBase extends DrupalUnitTestBase { - var $default_storage = 'field_sql_storage'; /** * Modules to enable. @@ -39,9 +38,7 @@ function setUp() { $this->installSchema('field', array('field_config', 'field_config_instance')); $this->installSchema('entity_test', 'entity_test'); $this->installSchema('field_test', array('test_entity', 'test_entity_revision', 'test_entity_bundle')); - - // Set default storage backend. - config('field.settings')->set('storage_default', $this->default_storage)->save(); + $this->installConfig(array('field')); } /** diff --git a/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php b/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php index fb7019e..4017513 100644 --- a/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php +++ b/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php @@ -59,6 +59,7 @@ protected function setUp() { $this->installSchema('field', array('field_config', 'field_config_instance')); $this->installSchema('entity_test', array('entity_test_mulrev', 'entity_test_mulrev_property_revision', 'entity_test_mulrev_property_data')); + $this->installConfig(array('field')); // Auto-create a field for testing. field_create_field(array(