108 votes

What does "The provided host name is not valid for this server" mean?

This error message is coming from a feature that was added to Drupal 8 to protect against HTTP Host header attacks. The feature is also described in the change record that was generated for the patch....
95 votes

How can I import the configuration on a different site?

Youu can get the UUID with drush config-get "system.site" uuid. You can change it with drush config-set "system.site" uuid [uuid].
user avatar
  • 1,085
57 votes

How do I remove a configuration object from the active configuration?

The easiest way to do this at the moment is to use drush php (or core-cli) to open an interactive session. Then use: Drupal::configFactory()->getEditable('system.menu.devel')->delete(); This ...
user avatar
  • 741
42 votes
Accepted

How to remove mymodule configurations on uninstall

The easiest way is to ensure that the config has a dependency on your module. dependencies: module: - yourmodule enforced: module: - yourmodule Then Drupal will automatically ...
user avatar
  • 81.5k
34 votes

How do I remove a configuration object from the active configuration?

Drush command to delete configuration object: drush config-delete <config_name>.
user avatar
  • 5,289
32 votes
Accepted

How do I update the configuration of a module?

As mentioned in the original question, and follow-up comments, there are a variety of contrib modules and manual methods to accomplish this. To do it automatically, or in a custom fashion, I think ...
user avatar
  • 4,962
29 votes

Import a single yml configuration file

You can use $ drush cim --partial --source=only-few-configs/ Your help says: $ drush cim --help Import config from a config directory. Examples: drush config-import --partial Import ...
user avatar
  • 3,491
23 votes

How can I import the configuration on a different site?

The Configuration Management only allow sync configuration between same site or project to avoid issues importing configuration from site a.com to b.com, to accomplish this validation Drupal 8 ...
user avatar
  • 3,491
22 votes
Accepted

Drupal 8 variable_get

In Drupal 7 $data = variable_get('test_content_types'); In Drupal 8 $data = \Drupal::state()->get('test_content_types'); For more information about about "get", "set", "delete" visit - Step ...
user avatar
19 votes

Import a single yml configuration file

You can import one configuration by running the following command: drupal config:import:single If you are trying to run multiple import you can create a chain for that. Command Documentation - ...
user avatar
18 votes

How do I update the configuration of a module?

I've found this Gist on GitHub, which reverts/reloads given module's configuration using drush: drush cim -y --partial --source=modules/path/to/module/config/install/
user avatar
  • 7,196
18 votes

How to prevent Devel module to be installed on production environments

Method: Drush Drush can ignore the enabled states of extensions when synchronizing configuration. drush cex --skip-modules=devel drush cim --skip-modules=devel With Drush CMI tools you can operate ...
user avatar
16 votes

How do I remove a configuration object from the active configuration?

You can use the following methods. Use the following code in hook_uninstall Drupal::configFactory()->reset('field.storage.bloom_stem.bs_twitter_ac'); OR in the yml file you can put the ...
user avatar
  • 2,697
15 votes
Accepted

How can I import the configuration on a different site?

Using Drupal Console You can override your current site's UUID with the value present in the configuration you want to import. You can achieve this with Drupal Console by overriding the uuid key for ...
user avatar
14 votes
Accepted

Drupal reuses its hash salt

I have migrated other CMS's to Drupal and had experience moving user accounts. Drupal's password algorithm is extremely good. The salt you are referring to in the settings.php is not used for ...
user avatar
  • 1,094
14 votes

How can I exclude configuration from import/export?

You can use the "Config Ignore" module: https://www.drupal.org/project/config_ignore Ever experienced that your site's configuration was overridden by the configuration on the filesystem, ...
user avatar
  • 291
14 votes

How do I fix a "Mismatched entity and/or field definitions" error on my configuration?

drush entity-updates (aka drush entup) has been deprecated as of Drupal 8.7.0. You either need to write an update script using hook_update_N(), or you can use the Devel Entity Updates module, which ...
user avatar
  • 15k
14 votes
Accepted

Best Way to Handle Variables Per Environment

You can create a new setting in your settings.local.php or settings.php file like: $settings['event_base_url'] = 'https://www.example.com'; or some people are adding switch block based on the server ...
user avatar
  • 13.6k
13 votes
Accepted

What are cloned sites in Drupal 8?

Cloned site means that you copied the database instead of installing twice from scratch. Drupal identifies two different sites as cloned sites by checking their uuid. If the uuids match, then it will ...
user avatar
  • 6,503
13 votes

How do I update the configuration of a module?

As I landed on this question as well but did not really find the correct answer for my situation here, I'd like to add another answer. Please note: Anti-pattern ahead! Use case When we're ...
user avatar
  • 829
13 votes
Accepted

Configuration export/import doesn't work

Configuration management is exporting exactly what it was designed to do: Export the configuration settings. The actual taxonomy terms themselves are sitting in the taxonomy_term_field_data table in ...
user avatar
13 votes
Accepted

What order should configuration import and module updates be run?

Updates must be run before configuration is imported A pending issue against core will ensure that the code and schema versions match before allowing configuration to be imported. Problems with ...
user avatar
  • 1,524
13 votes
Accepted

YML For Enabling a Contrib Module

To enable a module, you just need a line in core.extension.yml. However, you also need all the configuration the module provides. You could copy that over yourself from the config install and optional ...
user avatar
  • 81.5k
13 votes
Accepted

Manage config translations programmatically

The answer from @Smartsheet eng is correct if you want to load and read a specific translation as a config entity, see also How to progragrammatically get NodeType translated value in D8?. However, ...
user avatar
  • 81.5k
12 votes

What does "The provided host name is not valid for this server" mean?

This happens because trusted_host_patterns variable in your settings file. If you're working on the local environment and you want to override this, define the following section in your settings.local....
12 votes
Accepted

Attempt to create a field body that does not exist on entity type node

You attempted to create a field using configuration without creating the field storage configuration. In the field configuration YAML you can see a field_storage property. That is the id of the field ...
user avatar
  • 3,168
12 votes

How to load field configurations in code

The terminology is a bit confusing (as usual with Drupal), but here goes: Field storage configurations are defined by FieldStorageConfig. To load one, do this: $field = Drupal::entityTypeManager()-&...
user avatar
12 votes
Accepted

When to use mapping or sequence to define an array in a schema file?

A sequence is an unlimited list of identically structured elements. A mapping is a limited set of keys, each key has a possibly different structure. Your key has node types, so you're storing a list ...
user avatar
  • 81.5k
12 votes
Accepted

How can I programatically change the (D8 core) workflow state of an entity with Content Moderation?

A great example could be found in Content Moderation module's code. $entity->set('moderation_state', $new_state); if ($entity instanceof RevisionLogInterface) { $entity->setRevisionLogMessage(...
user avatar
11 votes

Saving values using variable_set through an array

It's the same: The variable_set function saves the variable to database serializing it. variable_get takes the variable from $conf where the variable is already unserialized. Example: $var1 = ...
user avatar
  • 2,115

Only top scored, non community-wiki answers of a minimum length are eligible