Imports configuration into the active configuration.
bool|null TRUE if configuration was imported successfully, FALSE in case of a synchronization error, or NULL if there are no changes to synchronize.
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;
}