function config_import

Imports configuration into the active configuration.

Return value

bool|null TRUE if configuration was imported successfully, FALSE in case of a synchronization error, or NULL if there are no changes to synchronize.

4 calls to config_import()
ConfigImportTest::testDeleted in drupal/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php
Tests deletion of configuration during import.
ConfigImportTest::testNew in drupal/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php
Tests creation of configuration during import.
ConfigImportTest::testUpdated in drupal/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php
Tests updating of configuration during import.
config_admin_import_form_submit in drupal/core/modules/config/config.admin.inc
Form submission handler for config_admin_import_form().
1 string reference to 'config_import'
ConfigImportUITest::testImportLock in drupal/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php
Tests concurrent importing of configuration.

File

drupal/core/includes/config.inc, line 202
This is the API for configuration storage.

Code

function config_import() {

  // Retrieve a list of differences between staging and the active configuration.
  $source_storage = drupal_container()
    ->get('config.storage.staging');
  $target_storage = drupal_container()
    ->get('config.storage');
  $config_changes = config_sync_get_changes($source_storage, $target_storage);
  if (empty($config_changes)) {
    return;
  }
  if (!lock()
    ->acquire(CONFIG_IMPORT_LOCK)) {

    // Another request is synchronizing configuration.
    // Return a negative result for UI purposes. We do not differentiate between
    // an actual synchronization error and a failed lock, because concurrent
    // synchronizations are an edge-case happening only when multiple developers
    // or site builders attempt to do it without coordinating.
    return FALSE;
  }
  $success = TRUE;
  try {
    $remaining_changes = config_import_invoke_owner($config_changes, $source_storage, $target_storage);
    config_sync_changes($remaining_changes, $source_storage, $target_storage);
  } catch (ConfigException $e) {
    watchdog_exception('config_import', $e);
    $success = FALSE;
  }
  lock()
    ->release(CONFIG_IMPORT_LOCK);
  return $success;
}